手记

Linux7搭建MySQL8

一、准备

查看Linux版本信息

uname -a

卸载Linux7自带的mariadb

# 查看相关包
rpm -qa | grep mariadb

# 卸载相关包
rpm -e 查出来的包名,有依赖的一起删掉就行 

下载相关包

downloads.mysql.com/archives/community/

二、安装

写文章用的安装包

上传

> 将下载的包上传到服务器上

RPM安装

> 顺序已经列出来了,不要错了

rpm -ivh  mysql-community-common-8.0.23-1.el7.x86_64.rpm
rpm -ivh  mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm
rpm -ivh  mysql-community-libs-8.0.23-1.el7.x86_64.rpm
rpm -ivh  mysql-community-client-8.0.23-1.el7.x86_64.rpm
rpm -ivh  mysql-community-server-8.0.23-1.el7.x86_64.rpm

检查

mysqladmin --version

三、启动

配置

> 默认的dataDir是对不上的。。需要修改下

vim /etc/my.cnf
datadir=/var/lib/mysql/mysql

启动

systemctl start mysqld
systemctl status mysqld

四、修改密码

查看默认密码

 cat /var/log/mysqld.log | grep password

登录

mysql -u root -p

临时修改符合规则的密码

alter user root@localhost identified by 'Root_123456';

更改密码策略

SHOW VARIABLES LIKE 'validate_password%';

set global validate_password.policy = low;
set global validate_password.length = 4; 
alter user root@localhost identified by '123456';
update user set host='%' where host='localhost';
systemctl restart mysqld; 
0人推荐
随时随地看视频
慕课网APP