Help Center/
Elastic Cloud Server/
Best Practices/
Setting Up an Application/
Deploying a Database/
Deploying MySQL on a Linux ECS/
Deploying MySQL on a CentOS ECS
Updated on 2025-08-06 GMT+08:00
Deploying MySQL on a CentOS ECS
- Create a CentOS ECS accessible to the internet. Select VNC or SSH remote login and log in to the ECS as user root.
- Run the following command to download the MySQL 8.0 RPM software package from the MySQL official website:
wget -i -c https://dev.mysql.com/get/mysql80-community-release-el7-10.noarch.rpm
- Run the following command to install the package downloaded in step 2:
yum -y install mysql80-community-release-el7-10.noarch.rpm
- Run the following command to install the MySQL community server and its dependency packages (skip the GPG signature verification):
yum -y install mysql-community-server --nogpgcheck
- Run the following command to check the MySQL version:
mysql -V
- Start MySQL and configure it to start automatically upon ECS startup:
systemctl start mysqld systemctl enable mysqld
- Check the status of MySQL:
systemctl status mysqld.service
Information similar to that shown in the following figure indicates that MySQL is running properly.
- Obtain the password of user root that was automatically set during MySQL installation:
grep 'temporary password' /var/log/mysqld.log
- Run the following command to harden the MySQL security:
mysql_secure_installation
Set parameters as required. For details, see the figure below.
- Enter the default password obtained in step 8.
- Set a password. The password must contain at least eight characters and consist of uppercase letters, lowercase letters, digits, and special characters.
- Enter N for Change the password for user root?.
- Enter Y for Remove anonymous users?.
- Enter Y for Disallow root login remotely?.
- Enter Y for Remove test database and access to it?.
- Enter 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 9 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 'kmXNB)60Ckap'; 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 12 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 12 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