MySQL Create Database: How-To with Examples

MySQL create a new database. In this video, you’ll learn how to create a new database in MySQL. Creating a new database is the first thing you need to do when starting a new project or setting up some data. I’ve done this many times before both in the IDE and at a command line. Let’s get into the video.

Now, there are three ways that you can create a new database in MySQL, and in this video I’ll show you all three. The first way that you can create a new database is in MySQL Workbench using the graphical user interface.

This is the least technical and it’s also quite easy. MySQL Workbench is one of the most popular SQL IEDs from MySQL and is freely available from the MySQL website. So, how do you create a database in MySQL Workbench?

The first step is to connect to the server, this is true for all of the methods I’ll show here. I’ll show you how to connect to the server in a different video as there are a few things to do. So, I’ll assume you’ve already connected. Your MySQL Workbench window should look something like this before you connect, so click on one of the connections to connect. Your MySQL Workbench screen should look something like this.

A database in MySQL Workbench is called a schema. To create a new database, you create a new schema. There are two places to create a new schema, you can click this button here on the toolbar, and if you hover over it it says, create a new schema in the connected server. Alternatively, you can right-click anywhere in the schemas tab on the left and select create schema from the menu that appears, in either case you get a new tab that opens.

This new tab is called the schema editor and it lets you create a new database on the server.

In the schema name box, you enter the name of the new schema or new database.

Generally, a database name should only include letters, numbers and underscore characters.

So, enter a database name here. You can select a character set and collation from the list, but for now we can just leave it as default. Click apply in the bottom right.

A window will appear to confirm the creation of the new schema. You can save the SQL command used to create it, it says create schema, but this is the same as create database.

Click apply in the bottom right to run the command. The schema or database is then created, a confirmation window is shown saying the database has been created, then click the close button. You should now see the database shown on the left in the list of schemas.

If you don’t see it, you can click on the circular refresh button on the top right of the schema panel.

When you create a database it’s not set to the active database by default, this means if you want to run further queries on it, you need to make it active. To do that you simply double click on it in the schemas panel, this will change the database name to bold, indicating it’s the active database. So, that’s one method of creating a new database in MySQL. The second way to create a new database in MySQL is to use an SQL query statement.

You can write an SQL statement inside an SQL window to create the database, this is often faster to do and can be repeated especially if it’s in an existing file. To do this, go to a new SQL window by clicking on the new SQL tab. You don’t need a new tab for this, but you just need somewhere to write the SQL and I find a new tab is easier. Entering the command create database, followed by the name of your database.

The name should include only letters, numbers and underscores, which are the same rules we mentioned earlier.

Then enter a semicolon, this will finish the statement. To run the command, click on either of the two execute buttons. The create database command will run and you’ll see a message in the action output panel at the bottom saying it was successful. To see it in the list of databases on the left, just click the circular refresh button. Now you can double click on the database to make it active. You can also do this using SQL.

To make it the active database, type use and then the database name, run that command by clicking inside it and clicking the run statement button. This new database is now the active database. So, that’s the second method of creating a database. There is one more method.

The third method to create a new database is using the command line. This is done using the Mac terminal or the Windows command line and not inside an IDE. To do this open a terminal window or command line, I’m running this on a Mac but it should be similar for Windows. Log into MySQL by running the MySQL command, add your user and database details into this command and press enter. Once you do this, you should see a MySQL prompt, at this prompt you can enter the same query as you did in MySQL Workbench.

You went to create database, then your database name, then a semicolon, press enter, and the database is created.

Into the command use database name, a semicolon and then press enter to run the command. The database is then created and is the active one. To show the list of databases on the server, type the command show databases and press enter. This will show a list of databases including the new database you just created.

So, that’s the third method to create a new database in MySQL. In summary, you can create a new database in MySQL by using the buttons or options in MySQL Workbench, by using an SQL command in your IDE, or by using the MySQL command line. If you learned something new from this video, make sure to subscribe to my channel.

If you want to learn more about database design and development visit databasestar.com, that’s where I share my best database related content.

Which step from this tutorial was the one you likely use the most? Was it the method with the command line? Or the method we right-clicking in the MySQL Workbench? Or running an SQL query? Thanks for watching.

https://www.supersalesmachine.com/pdf/dl2.php?file=23ProvenTacticsWriteSalesLetters&hop=tonym187

https://empowerour.aidady.com/webtool

(MMMBop’s) Click Bank Success System
https://warriorplus.com/o2/a/lg078n/0


Discover more from Making Money Is Easy

Subscribe to get the latest posts sent to your email.

About amorosbaeza1964

Hello, my name is Jose Amorós first of all I wish you a warm welcome to my blogs. It will be a pleasure to share with all of you information about my career and thus evaluate knowledge that will be beneficial for both of us. If you wish, you can contact us through the form, thank you!
This entry was posted in Computer Networks and tagged , , , . Bookmark the permalink.

Leave a Reply