How to create a database in MySQL?
To create a MySQL database, you need to follow the following steps:
- Open the MySQL client using the command line interface or a graphical interface tool such as phpMyAdmin.
- Log in to the MySQL server with your username and password.
- To create a database, use the statement CREATE DATABASE followed by the name of the database, for example CREATE DATABASE mydatabase;.
- To confirm if the database has been successfully created, you can use the command SHOW DATABASES; to view a list of all databases, which should include the newly created database.
- To use a newly created database, you can use the USE statement followed by the name of the database, for example USE mydatabase;
- You can now begin creating tables and adding data in the database.
The above are the basic steps to establish a database, the specific operations can be adjusted according to actual needs.