2021-12-16

ARM64架构下面安装mysql5.7.22

MySQL下载地址为:

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

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

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

2.安装依赖库

yum install -y libaio*

3. 下载解压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/

4.配置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

设置开机启动

cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
systemctl enable mysqld(报错不影响)

5. 添加环境变量

vim /etc/profile

添加下面两行代码:
export MYSQL_HOME=/usr/local/mysql
export PATH=MYSQL_HOME/bin

source /etc/profile

  1. 初始化启动mysql

开启mysql

systemctl start mysqld

查看状态

systemctl status mysqld


image

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

无密码初始化登录

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

建立软链接

ln -s /usr/local/mysql/bin/mysql /usr/bin

修改密码

使用:mysql -u root 进行登录

mysql> use mysql;
Database changed
mysql> select User from user;  #此处为查询用户命令
+-----------+
| User      |
+-----------+
| *******  |
| mysql.sys |
| root      |
+-----------+
3 rows in set (0.00 sec)

mysql> update user set password=password("*******") where user="*******";  #修改密码报错
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> update mysql.user set authentication_string=password('*******') where user='*******';  #修改密码成功
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;  #立即生效
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

n>mysql -u ******* -p #以该用户登录成功.
Enter password: ********
…………………………
mysql>

导入数据

把上传上去的sql导入到数据库中

按照下面的三个步骤,快速导入这个sql文件

复制代码代码如下:

mysql>use yourdatabasename;
mysql>set names utf8;
mysql>source /tmp/database.sql;

然后屏幕上就会不断的滚,最后提示导入成功。

最后,记得将database.sql删除

你可能感兴趣的:(2021-12-16)