ARM64架构下mysql5.7.22下载地址

https://obs.cn-north-4.myhuaweicloud.com/obs-mirror-ftp4/database/mysql-5.7.27-aarch64.tar.gz

1安装与启动

1.1安装mysql

# 添加mysql用户组和mysql用户,用于隔离mysql进程

[root@localhost ~]# groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql

# 安装依赖库

[root@localhost ~]# yum install -y libaio*

[root@localhost ~]# tar xvf mysql-5.7.27-aarch64.tar.gz -C /usr/local/

1.2配置mysql

重命名

[root@localhost ~]mv /usr/local/mysql-5.7.27-aarch64 /usr/local/mysql

创建数据目录和日志目录

[root@localhost ~]mkdir -p /usr/local/mysql/logs

[root@localhost ~]mkdir -p /usr/local/mysql/data

更改用户和用户组

[root@localhost ~]chown -R mysql:mysql /usr/local/mysql

添加依赖到服务器依赖库

[root@localhost ~]cp -rf /usr/local/mysql/extra/lib* /usr/lib64/

替换旧依赖

[root@localhost ~]mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.old

[root@localhost ~]ln -s /usr/lib64/libstdc++.so.6.0.24 /usr/lib64/libstdc++.so.6

设置开机启动

[root@localhost ~]cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@localhost ~]chmod +x /etc/init.d/mysqld

[root@localhost ~]systemctl enable mysqld

修改启动脚本中的basedir和datadir

创建my.cnf软链接

[root@localhost ~]ln -sf /usr/local/mysql/my.cnf /etc/my.cnf

修改my.cnf

[root@localhost ~]vim my.cnf

其中开头一部分配置改为:

[client]

port = 3306

socket =/usr/local/mysql/mysql.sock

[mysqld]

port = 3306

socket = /usr/local/mysql/mysql.sock

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

pid-file = /usr/local/mysql/data/mysql.pid

log-error=/usr/local/mysql/data/mysql.err

user = mysql

添加环境变量

[root@localhost ~]vim /etc/profile

# 在尾部添加

export MYSQL_HOME=/usr/local/mysql

export PATH=$PATH:$MYSQL_HOME/bin

添加完成后刷新

[root@localhost ~] source /etc/profile

1.3初始化以及启动数据库

初始化数据库

[root@localhost ~]mysqld –initialize-insecure –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data

启动数据库

[root@localhost ~]systemctl start mysqld

查看数据库状态

[root@localhost ~]systemctl status mysqld

到这里表示mysql已经安装成功了

2登录可能遇到的问题

2.1解决MySQL不需要密码就能登录问题

上面方法安装成功后可能不需要密码就能登录,解决问题步骤如下

# 1.#登录mysql
[root@localhost ~]# mysql -u root -p
# 2.切换为mysql数据库
mysql> user mysql;
mysql> update user set authentication_string=password(“你的密码”) where user=”root”;
mysql> flush privileges;
mysql> quit;

2.2远程无法连接

mysql> use mysql;
Database changed
mysql> grant all privileges on *.* to root@’%’ identified by “你的密码”;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;