获取软件包
[root@openEuler-node1 ~]# wget -c https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
[root@open-Euler-node3 mysql]# yum install ncurses-compat-libs #依赖
安装
[root@openEuler-node1 ~]# groupadd -g 27 -r mysql
[root@openEuler-node1 ~]# useradd -u 27 -g 27 -c 'MySQL Server' -r -s /sbin/nologin mysql
[root@openEuler-node1 ~]# tar xf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
[root@openEuler-node1 ~]# ln -sv /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64/ /usr/local/mysql
[root@open-Euler-node3 ~]# cd /usr/local/mysql
[root@open-Euler-node3 mysql]# mkdir mysql-files
[root@open-Euler-node3 mysql]# chown mysql:mysql mysql-files
[root@open-Euler-node3 mysql]# chmod 750 mysql-files
初始化
[root@open-Euler-node3 mysql]# bin/mysqld --initialize --user=mysql
生成密钥对
[root@open-Euler-node3 mysql]# bin/mysql_ssl_rsa_setup
命令行启动的指令 安全 指定用户mysql 在后台启动
[root@open-Euler-node3 mysql]# bin/mysqld_safe --user=mysql &
配置环境变量
[root@open-Euler-node3 mysql]# vi /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin/
[root@open-Euler-node3 mysql]# source /etc/profile.d/mysql.sh
登录并修改密码
[root@open-Euler-node3 mysql]# mysql -uroot -p'tfx9LsEG4g%H'
mysql> alter user root@localhost identified by 'MySQL@123';
提供服务脚本
停止服务:[root@open-Euler-node3 mysql]# mysqladmin -uroot -p'MySQL@123' shutdown
[root@open-Euler-node3 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
配置成系统服务
[root@open-Euler-node3 mysql]# chkconfig --add mysqld
提供配置文件
[root@openEuler-node1 ~]# scp /etc/my.cnf 192.168.136.57:/etc/
[root@openEuler-node1 ~]# scp -r /etc/my.cnf.d/ 192.168.136.57:/etc/
[root@open-Euler-node3 etc]# cd /etc/my.cnf.d/
[root@open-Euler-node3 my.cnf.d]# vim mariadb-server.cnf
[mysqld]
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
socket=/tmp/mysql.sock
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
登陆mysql
[root@open-Euler-node3 my.cnf.d]# mysql -uroot -pMySQL@123