Create a new mysql user and database digitalocean ubuntu
Here are the steps to create a new MySQL user and database on a DigitalOcean Ubuntu server:
Step 1: Connect to your MySQL server
Open a terminal and connect to your DigitalOcean Ubuntu server using SSH. Then, connect to your MySQL server using the following command:
mysql -u root -p
Replace root
with the root username and p
with the password you set during the installation process.
Step 2: Create a new database
Create a new database using the following command:
CREATE DATABASE mydatabase;
Replace mydatabase
with the name of your new database.
Step 3: Create a new MySQL user
Create a new MySQL user using the following command:
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
Replace myuser
with the username you want to create and mypassword
with the password you want to set.
Step 4: Grant privileges to the new user
Grant the new user privileges to access the database you created in Step 2 using the following command:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'%';
This command grants the user all privileges on the mydatabase
database.
Step 5: Flush the privileges
Flush the privileges to apply the changes using the following command:
FLUSH PRIVILEGES;
Step 6: Verify the new user and database
Verify that the new user and database have been created successfully by running the following commands:
mysql -u myuser -pmypassword mydatabase
This command should connect you to the mydatabase
database using the myuser
username and mypassword
password.
That's it! You have now created a new MySQL user and database on your DigitalOcean Ubuntu server.