MySQL: How to create a database


To create a simple database (e.g. if you need to create one for a WordPress or Wiki install) use the following after logging in to MySQL as the root user:


create database [nameOfDatabase];


Don’t forget the ; at the end, or you’ll end up on a new line consisting of a > prompt waiting for more input. You can put the ; in then if you forgot to complete the command. An example of the above would be:


create database wikiDB;


…which would create the database named wikiDB. You should see the following on a successful command:


Query OK, 1 row affected (0.04 sec)






If that is all you had to do you can now exit MySQL by typing:




…and you’re done!