Creating a MySQL database via the command line

8 04 2011

So you followed the MySQL 5 installation guide and have MySQL installed and ready to go. The next step will be to create a user and database so you can start using MySQL, and in this guide we’ll show you how the basics of how to create a database on your Windows based system. There are many ways to do this as there are a lot of support tools out there for MySQL. In this guide though we’ll stick to the basics and show you how to add a database using the MySQL command line client.

The MySQL command line client provides you with a means of interacting with your MySQL server from the command line (duh!), and is installed as a part of the MySQL Server installation process. GUI clients tend to be favoured these days, but it is important to become familiar with the MySQL command line client syntax as it is very useful for automation of important tasks such as backups (not covered in this guide).

  • Start the MySQL command line client by selecting the MySQL Command Line Client item from your MySQL program group in your start menu.
  • The MySQL command line client will prompt you for the root password. Enter it and push enter.
  • To create a database simply type in;


  • This will create a database called testdb. Simply replace testdb with the name you want to call your database.
  • Finally, lets verify that the database has been created. Type in;


  • This will list all the databases on your server, and you’ll see our testdb database listed.
  • Refer to figure 1 below to see an example of the MySQL command line output you would expect to see by running these commands.

figure 1

That is it, you now have a database using all the server default values ready to use. If you wish to create the database using values other than the default, our would like to read about additional options then I suggest you have a read of the CREATE DATABASE syntax documentation on the MySQL site.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: