阅读量:0
安装mysql
1.下载安装包
[root@mysql2 ~]# wget https://downloads.mysql.com/archives/[get](https://so.csdn.net/so/search?q=get&spm=1001.2101.3001.7020)/p/23/file/mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
2.解压
[root@mysql2 ~]# tar -xf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
3.卸载mariadb
[root@mysql2 ~]#yum -y remove mariadb
4.安装依赖包
#直到安装好mysql-community-server-8.0.33-1.el7.x86_64.rpm为止 [root@mysql2 ~]# rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm 警告:mysql-community-server-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY 错误:依赖检测失败: mysql-community-client(x86-64) >= 8.0.11 被 mysql-community-server-8.0.33-1.el7.x86_64 需要 mysql-community-common(x86-64) = 8.0.33-1.el7 被 mysql-community-server-8.0.33-1.el7.x86_64 需要 mysql-community-icu-data-files = 8.0.33-1.el7 被 mysql-community-server-8.0.33-1.el7.x86_64 需要 [root@mysql2 ~]# rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm 警告:mysql-community-server-8.0.33-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-server-8.0.33-1.e################################# [100%]
5.初始化配置mysql
[root@mysql2 ~]#mysqld --initialize
6.修改/etc/my.cnf配置文件
#启动服务出现错误 [root@mysql2 ~]# vim /etc/my.cnf #添加内容 explicit_defaults_for_timestamp=true #强制、递归地删除 /var/lib/mysql/目录下的所有文件和子目录 [root@mysql2 ~]# rm -rf /var/lib/mysql/*
7.启动服务
[root@mysql2 ~]# systemctl start mysqld
8.设置开机启动mysql服务
[root@mysql2 ~]#systemctl start mysqld.service
9.获得初始密码
[root@mysql2 ~]# cat /var/log/mysqld.log|grep password
10.使用初始密码登录
[root@mysql2 ~]# mysql -uroot -p Enter password: Rej+/6tQ#5LW
11.重新设置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Hui@2003';
12.远程修改权限
mysql> create user 'root'@'%'identified with mysql_native_password by 'Hui@2003'; mysql> grant all privileges on *.* to 'root'@'%' with grant option;
13.刷新
mysql> flush privileges;