Linux7搭建MySQL8

1、準備

查看Linux版本信息

uname -a

file

卸載Linux7自帶的mariadb

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

# 卸載相關包
rpm -e 查出來的包名,有依賴的一塊兒刪掉就行

下載相關包

https://downloads.mysql.com/archives/community/
圖中標註的幾個是須要下載的mysql

2、安裝

寫文章用的安裝包

上傳

將下載的包上傳到服務器上

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

3、啓動

配置

默認的dataDir是對不上的。。須要修改下
vim /etc/my.cnf
datadir=/var/lib/mysql/mysql

啓動

systemctl start mysqld
systemctl status mysqld

4、修改密碼

查看默認密碼

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

登陸

mysql -u root -p

臨時修改符合規則的密碼

alter user root@localhost identified by 'Root_123456';

更改密碼策略

SHOW VARIABLES LIKE 'validate_password%';

file

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;
相關文章
相關標籤/搜索