In this tutorial, you'll learn how to create a MySQL database using the command line and MySQL WorkBench. So, whether you prefer command-line tools or graphical user interfaces, this article covers both options.
It only takes one command to create a MySQL database. Just make sure you've connected to your instance first, then run the following command:
mysql> CREATE DATABASE [database_name];
Just remember to replace the text
[database_name] with the name of the database you'd like to create.
That's it! You can also check if your database exists first before attempting to create it by running this command instead:
mysql> CREATE DATABASE IF NOT EXISTS [database_name];
Then, to switch over to your newly created MySQL database, enter this command:
mysql> USE [database_name];
To create a MySQL database using MySQL Workbench, you can follow these steps:
- 1. Launch MySQL Workbench and select the instance where you want to house your new database:
- 2. Click the "Create a new schema" icon near the top-left of the screen.
- 3. Enter a name for your new database, then click the "Apply" button.
- 4. Then, it'll ask you to confirm your database creation. Click the "Apply" button here.
And now your new MySQL database has been created:
Using the information in this article, you learned how to create a MySQL database using the command line and MySQL Workbench.