由于鲲鹏的流行趋势,尝试基于arm的mysql安装

网上很多教程缺斤少两,总是差点意思,亲测后总结一下内容

此教程仅适用于mysql5版本,大于mysql5版本不确保正确

下载地址为:https://obs.cn-north-4.myhuaweicloud.com/obs-mirror-ftp4/database/mysql-5.7.27-aarch64.tar.gz
1. 添加mysql用户组和mysql用户,用于隔离mysql进程
[root@arm ~]# groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
2.安装依赖库
[root@arm ~]# yum install -y libaio*
3. 下载解压Mysql
[root@arm ~]# wget https://obs.cn-north-4.myhuaweicloud.com/obs-mirror-ftp4/database/mysql-5.7.27-aarch64.tar.gz
[root@arm ~]# tar xvf mysql-5.7.27-aarch64.tar.gz -C /usr/local/
4.配置Mysql
[root@arm ~]# mv /usr/local/mysql-5.7.27-aarch64 /usr/local/mysql
[root@arm ~]# mkdir -p /usr/local/mysql/logs
[root@arm ~]# chown -R mysql:mysql /usr/local/mysql
[root@arm ~]# ln -sf /usr/local/mysql/my.cnf /etc/my.cnf
[root@arm ~]# cp -rf /usr/local/mysql/extra/lib* /usr/lib64/
[root@arm ~]# mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.old
[root@arm ~]# ln -s /usr/lib64/libstdc++.so.6.0.24 /usr/lib64/libstdc++.so.6

# 设置开机启动
[root@arm ~]# cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@arm ~]# chmod +x /etc/init.d/mysqld
[root@arm ~]# systemctl enable mysqld
5. 添加环境变量
[root@ecs-arm ~]# vi /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

[root@ecs-arm ~]# source /etc/profile

随机密码初始化登录
# "–initialize"生成随机密码,在这里存储在/usr/local/mysql/logs/mysql-error.log
[root@ecs-arm ~]# mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[root@ecs-arm ~]# systemctl start mysqld
[root@ecs-arm ~]# systemctl status mysqld
# 查看随机密码
[root@ecs-arm ~]# cat /usr/local/mysql/logs/mysql-error.log | grep password

6.登录mysql修改密码(需要输入随机密码)

[root@localhost /]#  mysql -u root -p
Enter password:
mysql>set password for root@localhost = password('NiDeMiMaPassWord'); ----注意最结束符分号一定要写

7.开放远程连接

mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐