1.下载mysql

wget https://obs.cn-north-4.myhuaweicloud.com/obs-mirror-ftp4/database/mysql-5.7.27-aarch64.tar.gz
tar -xvf mysql-5.7.27-aarch64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.7.27-aarch64 /usr/local/mysql

2.添加mysql用户和组

groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql

3.配置MySQL

mkdir -p /usr/local/mysql/logs
chown -R mysql:mysql /usr/local/mysql 
ln -sf /usr/local/mysql/my.cnf /etc/my.cnf
cp -rf /usr/local/mysql/extra/lib* /usr/lib64/ 
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.old
ln -s /usr/lib64/libstdc++.so.6.0.24 /usr/lib64/libstdc++.so.6

4.设置开机启动并配置环境变量
在/etc/profile 输入如下两行

export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

然后使用source /etc/profile ,使用如下命令设置开机自启动

cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 
chmod +x /etc/init.d/mysqld
systemctl enable mysqld

5.初始化mysql并修改密码

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
systemctl start mysqld
mysql -u root 
use mysql;
update user set authentication_string=password('新密码') where user='root' and Host='localhost';
flush privileges;

6.开启root远程登录

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' with GRANT OPTION;
flush privileges;