How to Create a Database on a VPS?
If you have a virtual private server (VPS) and you want to create a database for your project, then follow these simple steps.
Step 1: Installing the MySQL Server
The first step is to install the MySQL server on your VPS. To do this, execute the command:
sudo apt-get update
sudo apt-get install mysql-server
Step 2: Creating the Database
Next, you need to create a new database in MySQL. To do this, execute the following commands:
mysql -u root -p
CREATE DATABASE database_name;
Step 3: Creating a User and Assigning Privileges
Create a new user for your database and assign them all the necessary privileges. This can be done as follows:
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'user'@'localhost';
Step 4: Completing the Setup
Congratulations! You now have a database on your VPS. Don’t forget to save the database connection details (host, name, user, password).
Good luck with your project!