Help Center/
Elastic Cloud Server/
Best Practices/
Setting Up an Application/
Deploying a Database/
Deploying MySQL on a Linux ECS/
Deploying MySQL on an Ubuntu ECS
Updated on 2025-08-06 GMT+08:00
Deploying MySQL on an Ubuntu ECS
- Create an Ubuntu ECS accessible to the internet. Select VNC or SSH for remote login.
- Run the following commands to update the ECS image source:
sudo apt update sudo apt upgrade
- Run the following command to install MySQL:
sudo apt -y install mysql-server
- Check the MySQL status and configure it to automatically start upon ECS startup:
sudo systemctl status mysql sudo systemctl enable mysql
- Run the following command to access MySQL:
sudo mysql
- Run the following command to set the password for user root:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'kmXNB)60Ckap';
- Run the following command to exit MySQL:
exit
- Run the following command to harden MySQL security as required:
mysql_secure_installation
- Enter the password configured in step 6.
- Enter y or Y if you want to configure a password policy.
- Set the password strength:
- Weak password: The password contains at least eight characters.
- Medium password: The password contains at least eight characters and consists of uppercase letters, lowercase letters, digits, and special characters.
- Strong password: The password contains at least eight characters, consists of uppercase letters, lowercase letters, digits, and special characters, and is checked against a dictionary attack.
Enter 2 to use a strong password.
- Enter y or Y for Change the password for root?.
Enter the new password of user root. The password must meet strong password requirements.
- Enter y or Y for Do you wish to continue with the password provided?.
- Enter y or Y for Remove anonymous users?.
- Enter y or Y for Disallow root login remotely?.
- Enter y or Y for Remove test database and access to it?.
- Enter y or Y for Reload privilege tables now?.
- Run the following command to log in to the database as user root of MySQL and enter the password configured in step 8 as prompted:
sudo mysql -u root -p
- Run the following command to create a database named workspace:
CREATE DATABASE workspace;
- Create a user and grant the user full access to the database. In the command, workspaceuser indicates the database username, and xxxxx indicates the password of the database user. You can set them as required.
CREATE USER 'workspaceuser'@'localhost' IDENTIFIED BY 'xxxxx'; GRANT ALL ON workspace.* TO workspaceuser@localhost;
- Run the following command to update the MySQL permission table to ensure that the permissions assigned in step 11 takes effect immediately:
FLUSH PRIVILEGES;
- Run the following command to exit the MySQL CLI:
exit
- (Optional) Run the following commands in sequence (enter the password configured in step 11 after the first command is executed) to check whether the database and user has been created and exit the MySQL CLI:
mysql -u workspaceuser -p SHOW DATABASES; exit
Parent topic: Deploying MySQL on a Linux ECS
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot