過(guò)程中一路選y
一.
vi /etc/selinux/config ,i進(jìn)入編輯模式,設(shè)置SELINUX=disabled,esc退出編輯模式,:wq保存退出(:w保存 :q退出)
reboot命令重新啟動(dòng)centOS
二.
替換yum源https://www.cnblogs.com/zzsdream/p/7405083.html
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
更新緩存
yum clean all
yum makecache
三. MySQL官方地址 MySQL Yum倉(cāng)庫(kù)的RPM安裝包
通過(guò)wget方式獲取yum包
wget http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
四. 安裝MySQL RPM安裝包
命令:
yum localinstall mysql80-community-release-el7-1.noarch.rpm
看到安裝MySQL8.0安裝完成后可到/etc/yum.repos.d/目錄下看到:
mysql-community.repo? mysql-community-source.repo
兩個(gè)文件,說(shuō)明MySQL Yum倉(cāng)庫(kù)添加成功。
五. 安裝MySQL
[root@*******0x2dru8ftg3uz yum.repos.d]# yum install mysql-community-server
完成之后數(shù)據(jù)庫(kù)會(huì)有一個(gè)初始密碼,可通過(guò)一下命令查看:
[root@*******2dru8ftg3uzlog]# sudo grep'temporary password'/var/log/mysqld.log
至此,MySQL8.0 安裝完成,下面進(jìn)行啟動(dòng)配置。
六.啟動(dòng)MySQL8.0
##啟動(dòng)MySQL服務(wù)? service mysqld start
##查看MySQL進(jìn)程? ps -ef |grep mysql?
##停止MySQL服務(wù):service mysqld stop
七.進(jìn)行一些必要的配置
1、修改初始密碼
##查看默認(rèn)密碼
shell> sudo grep 'temporary password' /var/log/mysqld.log
##使用默認(rèn)密碼登陸(使用該方法登陸數(shù)據(jù)庫(kù))
shell> mysql -uroot -p
#MySQL8.0修改密碼需要有大小寫(xiě)字母、數(shù)字、特殊字符組合
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lijiantao1998.';
#默認(rèn)情況下密碼策略要求密碼至少包含一個(gè)大寫(xiě)字母、一個(gè)小寫(xiě)字母、一個(gè)數(shù)字和一個(gè)特殊字符,并且總密碼長(zhǎng)度至少為8個(gè)字符。
否則回報(bào)出:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
validate_password is installed by default. The default password policy implemented by validate_password requires that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.
2、外網(wǎng)/客戶(hù)端訪問(wèn)問(wèn)題
客戶(hù)訪問(wèn)報(bào)錯(cuò):ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL
解決方案:
? ? 服務(wù)端登陸MySQL,修改user表登陸用戶(hù)的host。
shell>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql? ? ? ? ? |
+---------------------------+
| columns_priv? ? ? ? ? ? ? |
此處省略n個(gè)表
| time_zone_transition? ? ? |
| time_zone_transition_type |
| user? ? ? ? ? ? ? ? ? ? ? |
+---------------------------+
33 rows in set (0.00 sec)
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.07 sec)
Rows matched: 1? Changed: 1? Warnings: 0
客戶(hù)端建立連接報(bào)錯(cuò):2059 - authentication plugin 'caching_sha2_password' ...?
解決方案:
執(zhí)行sql:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Lijiantao1998.';
另外阿里云的防火墻默認(rèn)端口是不開(kāi)放的,需要在控制臺(tái)進(jìn)行設(shè)置,不打開(kāi)端口外網(wǎng)也是訪問(wèn)不到的。
在防火墻上添加mysql的3306端口即可
終于大功告成。
原文鏈接(https://blog.csdn.net/qq_32672633/article/details/80325470)