Installing a MySQL Database (Community Edition)
This section describes how to initialize disks and install a MySQL database (community edition).
Log In to the ECS
- Log in to the management console.
- Click in the upper left corner of the management console and select EU-Dublin.
- Under the service list, choose Compute > Elastic Cloud Server.
- Locate the ECS ecs-mysql and click Remote Login in the Operation column.
- Select CloudShell-based Login.
- Enter the password of user root.
The password is the one you specified during the ECS creation.
Initializing Disks
- Create the mysql folder.
mkdir /mysql
- View data disk information.
fdisk -l
The command output is as follows.
- Initialize the data disk.
mkfs.ext4 /dev/vdb
- Attach the disk.
mount /dev/vdb /mysql
- Check whether the disk is attached.
df -h
If the following output is returned, the disk is attached.
- Create a folder and switch to the install folder.
mkdir -p /mysql/install/data
mkdir -p /mysql/install/tmp
mkdir -p /mysql/install/file
mkdir -p /mysql/install/log
cd /mysql/install
- Download and install How Can I Install the MySQL Client?
- Initialize the MySQL client.
/mysql/install/mysql-8.0.22/bin/mysqld --defaults-file= /etc/my.cnf --initialize-insecure
- Start the MySQL client.
nohup /mysql/install/mysql-8.0.22/bin/mysqld --defaults-file= /etc/my.cnf &
- Connect to the MySQL client.
/mysql/install/mysql-8.0.22/bin/mysql
- Create user root and assign the required permissions to it.
grant all privileges on *.* to 'root'@'%' identified by 'xxx' with grant option;FLUSH PRIVILEGES;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.