一、必要说明
1、系统:openEuler操作系统
2、版本:MySQL - 8.0.36
3、下载地址:https://dev.mysql.com/get/Downloads/MySQL-8.0
二、安装步骤
1、下载glibc版本的Mysql
[root@node2 ~]# wget -c https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
2、新建用户以安全方式运行进程
欧拉操作系统需下载tar和xz工具
[root@node2 ~]# dnf install tar xz -y
[root@node2 ~]# groupadd -r -g 306 mysql
[root@node2 ~]# useradd -g 306 -r -u 306 -s /sbin/nologin mysql
3、安装并初始化mysql
[root@node2 ~]# tar xf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
[root@node2 ~]# cd /usr/local/
[root@node2 local]# tar xf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
[root@node2 local]# ln -sv /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64/ /usr/local/mysql
‘mysql’ -> ‘mysql-8.0.28-linux-glibc2.12-x86_64’
[root@node2 local]# mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 2023-12-21T08:09:03.520176Z 1 [Note] A temporary password is generated for root@localhost: 7YKx-o5(:jb_ #初始化会生成默认密码
4.提供配置文件和服务脚本
[root@node2 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@node2~]# chkconfig --add mysqld
[root@node2 ~]# chkconfig mysqld on
[root@node2 ~]# vim /etc/my.cnf.d/mysql-server.cnf
5.添加环境变量
[root@node2 mysql]# cd /etc/profile.d/
[root@node2 profile.d]# vim mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
[root@node2 profile.d]# source mysql.sh
6.重启并修改密码
[root@node2 ~]# systemctl restart mysqld
[root@node2 ~]# mysql -uroot -p
Enter password:7YKx-o5(:jb_
mysql> alter user root@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye