以下操作在Centos7.5上實操成功。
一、先卸載MariaDB
rpm -qa | grep -i mariadb(檢查有沒有mariadb)
rpm -e ?--nodeps? mariadb-libs-5.5.56-2.el7.x86_64(不檢查依賴直接卸載)
二、檢查是否有mysql殘留(如有最好也卸載干凈,下面重新安裝)
rpm -qa |?grep?mysql
三、下載mysql庫(要連網(wǎng))
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
四、安裝mysql庫
yum -y install mysql80-community-release-el7-3.noarch.rpm
五、重新獲取mysql的GPG(不執(zhí)行的話下一步y(tǒng)um安裝會報錯)
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
六、安裝mysql(默認安裝mysql8.0)
yum -y install mysql-community-server
七、開啟mysql服務
systemctl start mysqld
八、檢查mysql運行狀態(tài)(非必要操作)
systemctl status mysqld(如沒運行,執(zhí)行systemctl start mysqld)
?九、查看默認密碼(非必要操作)
cat /var/log/mysqld.log | grep password
到這里,mysql8.0已經(jīng)安裝完成,為了更方便地使用mysql,下面是修改密碼和開啟遠程訪問的操作。
十、設置mysql免密碼登錄,以便進行修改密碼操作
vim /etc/my.cnf(編輯文件)
添加skip-grant-tables
wq!保存退出
systemctl? restart? mysqld(重啟服務讓配置生效)
十一、登錄mysql(已免密,按任意鍵登錄)
mysql -uroot -p
十二、修改mysql默認密碼
use mysql;(切換到mysql庫)
SHOW variables LIKE 'validate_password%';(非必要操作,查詢表)
set global validate_password.policy=0;(把密碼限制調(diào)低)
set global validate_password.length=4;(把密碼限制字數(shù)調(diào)低)
flush privileges;(刷新生效)
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';(設置密碼123456)
flush privileges;(刷新生效)
十三、設置root賬號遠程訪問
select user,host,plugin from user;(查詢表)
?update user set host = '%' where user = 'root';(設置root任意地址訪問)
update user set plugin = 'mysql_native_password' where user = 'root';(非必要操作,因mysql8.0已改為新插件caching_sha2_password,用navicat12登錄會報錯,可執(zhí)行這條命令改回舊插件mysql_native_password即可,或者升級navicat到16版本,16版本已支持caching_sha2_password)
flush privileges;(刷新生效)
exit(退出mysql)
十四、取消免密登錄
vim /etc/my.cnf(編輯文件)
把skip-grant-tables刪除
wq!保存退出
systemctl? restart? mysqld(重啟服務讓配置生效)
十五、開放3306數(shù)據(jù)庫默認端口(遠程登錄要開)
systemctl? status? firewalld(檢查防火墻是否開啟,如沒運行,執(zhí)行systemctl? start? firewalld)
firewall-cmd --permanent? --add-port=3306/tcp(永久添加3306端口)
firewall-cmd ?--reload(刷新生效)
firewall-cmd --list-ports(非必要操作,檢查是否開啟端口)
十六、驗證登錄
本地登錄mysql成功
?navicat16遠程登錄mysql成功文章來源:http://www.zghlxwxcb.cn/news/detail-414630.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-414630.html
到了這里,關于Centos7安裝mysql8.0操作步驟(yum安裝方法)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!