Create MySQL Database
Create MySQL Databse with cPanel
- Firstly, sign into your Control Panel.
- Then, click on Databases.
- Enter a database name and press Add.
- Lastly, enter a username and password for the database and press Update.
- Your connection is localhost and the username and passwords are what you have specified in the setup. This data is required when a script associate with mySQL server.
Create MySQL Database with Command
For those who are running a Linux server with MySQL but no cPanel, you can use MySQL commands to easily create a MySQL database, database user, password, and assign all privileges to the user for the database.
- Firstly, SSH into your server.
- Secondly, login to MySQL as root user.
- Then, create a new database user with:
GRANT ALL PRIVILEGES ON *.* TO 'db_user'@'localhost' IDENTIFIED BY 'P@s$w0rd123!';
NOTE: Be sure to replace db_user and P@s$w0rd123! with the actual name and the password to be given to the database user. - After that, log out of MySQL by typing:
\q
. - Log in as the new database user you just created.
mysql -u db_user -p
Then, type the new database user’s password and press Enter. - Lastly, create a new database:
CREATE DATABASE db_name;NOTE: Be sure to modify db_name with the actual name you would like to give the database.
We hope this article helped you to learn how to create MySQL Database. For more articles, please go to Knowledge Base.