1.连接服务器
2.root用户下:添加mysql用户组和mysql用户
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
3.安装依赖库
yum install -y libaio*
4.进入/usr/local
下载Mysql:wgethttps://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
5.配置Mysql
mv /usr/local/mysql-5.7.27-aarch64 /usr/local/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
6.设置开机启动
cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
systemctl enable mysqld
7. 添加环境变量
vim /etc/profile
键盘输入“i”,开启编辑模式
添加下面两行代码:
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
保存退出:Esc键 再输入 :wq
source /etc/profile
8.初始化启动mysql
//无密码初始化登录
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
9.开启mysql
systemctl start mysqld
10.查看状态
systemctl status mysqld
//出现以下说明安装成功
11.修改密码(因为初始化时设置无密码登录)
进入mysql安装路径的bin目录下:cd /usr/local/mysql/bin
执行 ./mysql -u root -p
mysql>SET PASSWORD = PASSWORD('123456'); // 设置密码123456
mysql>ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>FLUSH PRIVILEGES;
mysql>exit
1.报错2003:
需要关闭服务器防火墙
systemctl stop firewalld
2.报错1130:
存在用户权限问题
详细解决方案借助:
(27条消息) 解决远程连接mysql错误1130代码的方法_大胖东的博客-CSDN博客_1130 mysql无法连接https://blog.csdn.net/qq_42583263/article/details/121399301
修改过后重启 mysql服务即可:service mysqld restart
现在就可以了!