CentOS 7.9 安装MySQL 8.0.26 Commun
1.官网下载MySQL 8.0 社区版
2.进入/usr/local,创建mysql目录
cd /usr/local
mkdir mysql
3.用Xftp上传到/usr/local/mysql
4.卸载mariadb
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps
5.解压tar包
tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar
6.安装 rpm -ivh xxxxxx.rpm
必须安装:
mysql-community-client-8.0.26-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
mysql-community-common-8.0.26-1.el7.x86_64.rpm
mysql-community-libs-8.0.26-1.el7.x86_64.rpm
mysql-community-server-8.0.26-1.el7.x86_64.rpm
不用安装:
mysql-community-devel-8.0.26-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.26-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
mysql-community-test-8.0.26-1.el7.x86_64.rpm
7.安装时若缺少依赖(perl)
yum install perl.x86_64
8.初始化mysql
mysqld --initialize
9.启动mysql
service mysqld start
service mysqld status
10.启动报错,需给mysql用户分配权限
chown -R mysql:mysql /var/lib/mysql/
10.修改密码
mysql -u root -p
输入上面初始化生产密码:hDT5rr0KWd?_
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
11.修改权限为所有机器可访问
show databases;
use mysql;
select host, user, authentication_string, plugin from user;
localhost为本机可访问,%为所有机器可访问
12.防火墙打开端口:
firewall-cmd --add-port=3306/tcp --zone=public --permanent
firewall-cmd --reload
参考文章: