CentOS7 安装MySQL 8.0
目录
3. 解压到当前目录,mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
9. 使用root用户登录mysql ,并修改root用户密码
注:安装之前准备
yum install -y perl-Module-Install.noarch
yum install -y perl
yum install net-tools
1. 在usr/local目录下创建mysql安装目录
cd /usr/local
mkdir soft/mysql
2. 将资源放在MySQL文件下
3. 解压到当前目录,mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
4. 查看 mariadb 的安装包
rpm -qa | grep mariadb
5. 卸载mariadb
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
6. 依次安装
rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm
7. 查看已安装资源
rpm -qa | grep mysql
8. 初始化
# 初始化
mysqld --initialize
# 授权
chown mysql:mysql /var/lib/mysql -R
# 开启mysql服务
systemctl start mysqld
# 查看mysql 状态
systemctl status mysqld
# 查看root初始密码
cat /var/log/mysqld.log | grep password
9. 使用root用户登录mysql ,并修改root用户密码
# 回车之后输入前面的初始密码也就是(填上面查到的密码)
mysql -u root -p
输入:OWwkt20qsp%e
# 更新密码
ALTER USER "root"@"localhost" IDENTIFIED BY "自己的密码";
# 立即生效
FLUSH PRIVILEGES;
10. 远程连接
use mysql;
update user set host = '%' where user ='root';
# 更改加密方式
ALTER USER 'root'@'%' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
# 更新用户密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
11. 开启端口
# 开启3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 重启
firewall-cmd --reload