官网下载:https://downloads.mysql.com/archives/community/
上传到服务器,然后解压缩
tar -zxvf mysql-8.0.31-linux-glibc2.17-aarch64.tar.gz
mv mysql-8.0.31-linux-glibc2.17-aarch64 /usr/local/mysql-8
创建MySQL数据目录
mkdir -p /data
cd data
mkdir -p mysql
生成编辑配置文件
vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=xxx
basedir=/usr/local/mysql-8
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
初始化MYSQL
cd /usr/local/mysql-8/bin/
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql-8/ --datadir=/data/mysql/ --user=mysql --initialize
查看初始密码
cat /data/mysql/mysql.err
启动mysql
cp /usr/local/mysql-8/support-files/mysql.server /etc/init.d/mysql
/etc/init.d/mysql status
启动 service mysql start
更改密码
cd /usr/local/mysql-8/bin/
./mysql -u root -p
alter user 'root'@'localhost' identified by 'abc123,.';
更改访问权限
use mysql;
update user set host = '%' where user = 'root';
flush privileges;