How to create new database in mysql
To create a new database in MySQL, you can use the following steps:
Method 1: Using the MySQL Command-Line Tool
-
Open a terminal or command prompt and connect to your MySQL server using the following command:
mysql -u your_username -p
Replace
your_username
with your MySQL username andyour_password
with your MySQL password. -
Once connected, create a new database using the following command:
CREATE DATABASE your_database_name;
Replace
your_database_name
with the name you want to give your new database.
For example:
CREATE DATABASE my_new_database;
- Press Enter to execute the command. If the database is created successfully, you will see a message indicating that the database has been created.
Method 2: Using phpMyAdmin
- Open phpMyAdmin in your web browser by navigating to
http://your_server_ip/phpmyadmin
(replaceyour_server_ip
with the IP address of your server). - Log in to phpMyAdmin using your MySQL username and password.
- Click on the "Databases" tab.
- Click on the "Create database" button.
- Enter the name of your new database in the "Database name" field.
- Click on the "Create" button to create the database.
Method 3: Using a MySQL Client Tool
You can also use a MySQL client tool such as MySQL Workbench or HeidiSQL to create a new database.
- Open MySQL Workbench or HeidiSQL and connect to your MySQL server.
- Click on the "Database" tab.
- Click on the "Create database" button.
- Enter the name of your new database in the "Database name" field.
- Click on the "Create" button to create the database.
Regardless of the method you use, you can verify that the database has been created by running the following command:
SHOW DATABASES;
This will list all the databases on your MySQL server, including the new one you just created.