How do I create a new database for mysql?

Mondo Technology Updated on 2024-01-29

Hardware model: Lenovo Legion Y7000P

System version: Windows 11

Software version: MySQL 57、mysql 8.0

To create a new database through the MySQL client tool, follow these steps:

First, log in to the MySQL server with a user account with the following permissionscreate database

It will prompt you to enter your password. To authenticate, you need to enter the password for your user accountrootAnd press the followingenterkey:

Next, use the statement to display the databases available on the servershow databases。This step is optional.

You'll see an output like this.

Then, we entercreate databaseCommand with the name of the database, for exampletestdbThen press Enter:

It will return the following:

You've created a database.

To create a new database using MySQL Workbench, follow these steps:

First, launch MySQL Workbench and click on itSet up a new connectionbutton, as shown in the image below:

Second, type a name for the connection and clickTest ConnectionButton.

MySQL Workbench displays a dialog box that asks for the user's passwordroot

You will need to (1) enter the user's passwordroot, (2) checkedPasswords are saved in the vault, (3) clickOKButton.

Third, double-click on the connection namelocalto connect to the MySQL server.

MySQL Workbench opens the following window, which consists of four sections: Navigator, Query, Information, and Output.

Fourth, click on the toolbarCreate a new database in a connected server button:

In MySQL, schema is synonymous with database. Creating a new schema also means creating a new database.

Fifth, open the following window. You need to (1) enter a database name, (2) change the character set and collation (if necessary), and then clickApply".Button.

Sixth, MySQL Workbench will open the following window showing the SQL script that will be executed. Note,create schemaThe statement command has the same effect as statementcreate database

If everything looks good, you'll see the new database created and displayed inNavigatorPartiallyArchitecturetab.

Your new database is now created.

Using other visualization tools also allows you to easily create databases.

Related Pages