Download dbForge Studio for MySQL

This article provides a detailed overview of how to create databases in MySQL using different methods and tools, including the command line for MySQL, the workbench, and dbForge Studio.

MySQL is a relational database management system based on SQL. It is developed, distributed, and supported by Oracle Corporation. MySQL is free and open source software that is becoming increasingly popular due to its reliability, compatibility, cost effectiveness and comprehensive support.

MySQL has a branch, MariaDB, made by the original MySQL developers. MariaDB can replace MySQL because it has the same database structure and index.

Both MySQL and MariaDB support many popular operating systems, including but not limited to the following: Linux, Ubuntu, Debian, Microsoft Windows, and macOS.

Before you can start creating a new MySQL database, you need to download dbForge Studio for MySQL.

In this article, we examine different approaches to creating a MySQL database.

CREATE DATABASE: MySQL syntax example

The first way to CREATE a DATABASE in MySQL that should be mentioned is to use the CREATE DATABASE statement. This statement creates a database with the specified name. Remember, to use it, you need to have CREATE permission on the database.

CREATE DATABASE mydatabase;
Copy the code

Note:

IF you run the CREATE DATABASE statement without specifying IF NOT EXISTS and the DATABASE already EXISTS, an error occurs. Therefore, it is best to use the IF NOT EXISTS clause to prevent errors.

CREATE DATABASE IF NOT EXISTS mydatabase;
Copy the code

After executing the CREATE DATABASE statement, MySQL returns a message notifying the DATABASE that it was successfully created.

Create the database from the command line client

The MySQL Command Line Client is usually provided with the MySQL Server installation package. It is installed in two versions – UTF-8 supported and UTF-8 not. You can run the console client directly from the Start menu.

Create a MySQL database using the MySQL cli client: 1. Run the MySQL client. 2. Enter your password. 3. Run the create database command.

You can learn more about using the MySQL command line client in our How to Connect to MySQL Server article.

How do I create a database in MySQL Workbench

MySQL Workbench is a popular visual database tool for designing, developing, and managing MySQL databases.

How to create a database with MySQL Workbench:

1. Start MySQL Workbench, and then click the **+** button to open the ** Set up new Connection ** wizard.

2. Enter the connection name and user name, and click Test Connection. Enter a password in the dialog box and ask for a password. We enter

localhost

and

root

.

3. In the **MySQL Connections ** section of the Workbench start page, click the connection you want.

4. In the MySQL Workbench window that opens, click the Create New Mode on connected servers button on the main toolbar. Then enter the schema name, change the character set and collation if necessary, and click Apply.

5. In the ** Apply SQL scripts to database window, click Apply. Then, click Finish.

6. Check whether the database appears in the navigator.

Today’s workbench is one of the most popular professional tools for MySQL database development. But. Let’s look at how to create a new MySQL database using dbForge Studio for MySQL.

How to create a database using dbForge Studio for MySQL

DbForge Studio for MySQL provides a very simple and intuitive way to create new databases in MySQL. You don’t need to be a professional developer or DBA to start using dbForge Studio for MySQL.

1. First, you need to create the required connections. Click the New Connection button on the Database Explorer toolbar. Alternatively, go to the Database menu on the main toolbar and click New Connection.

2. In the Database Connection Properties window that opens, provide all the necessary credentials for the connection.

3. The new connection will appear in database Explorer. Right-click the connection name and choose New Database. Alternatively, go to the ** Database ** menu in the main toolbar, and click New Database.

4. In the New Database TAB, enter the name of the new database and select a character set and collation rule. You can examine the database script at the bottom of the window. After configuring everything as needed, click Apply Changes.

5. Check whether the newly created database is displayed on the MySQL server. To do this, right-click the connection name in Database Explorer, and then click Refresh.

After creating the database

When you have multiple databases on your MySQL server, to start using the created database, use the following statement:

USE database_name;
Copy the code

To create a new table in the database, use the following syntax:

CREATE TABLE [IF NOT EXISTS] table_name(column_1_definition, column_2_definition,... , table_constraints ) ENGINE=storage_engine;Copy the code

In the figure below, you can see how to create MySQL tables in dbForge Studio for MySQL. Studio has auto-complete, so you don’t have to type all the code.

To learn more about creating tables in MySQL, see our How to Use MySQL CREATE TABLE statement and CREATE tables through MySQL’s GUI tools.

To drop a table, use the following statement:

DROP DATABASE databasename;
Copy the code

DbForge Studio for MySQL allows you to visually delete databases without writing code. Simply right-click the database you want in Database Explorer and click Delete.

conclusion

As you can see, using dbForge Studio For MySql allows you to quickly and easily create new databases in a convenient and modern interface. The dbForge support team is ready to help you in case you run into any difficulties. Download dbForge Studio for MySQL and test the full functionality of all its features.