新裝的CentOS8,安裝最新版MySQL8.0.30

** 新裝的CentOS8
1.配置網(wǎng)絡服務
cd /etc/sysconfig/network-scripts
vi ifcfg-ens160? ?修改配置項:ONBOOT=yes【最后一行】
2.重啟網(wǎng)絡服務
nmcli networking off
nmcli networking on
如果啟動不了,提示Error:NetworkManager is not running,則需要手動啟動NetworkManager
systemctl start NetworkManager
現(xiàn)在就可以通過ip add查看ip地址了,能連上Xshenll了
3.配置下載源
cd /etc/yum.repos.d
創(chuàng)建備份:mkdir back? ? ? ? ? ? mv CentOS-* back
下載阿里云元數(shù)據(jù)文件:wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
建立新元數(shù)據(jù)緩存:yum makecache
4.安裝
wget https://repo.mysql.com/mysql80-community-release-el8-4.noarch.rpm
yum -y install mysql80-community-release-el8-4.noarch.rpm
yum -y install mysql-community-server
禁用CentOS自帶:sudo yum module disable mysql
5.啟動服務
啟動mysql服務:systemctl start mysqld.service
查看是否啟動mysql服務:systemctl status mysqld.service
6.修改密碼
查看mysql初始密碼:grep "password" /var/log/mysqld.log
進入mysql:mysql -u root -p
**密碼先修改一個符合規(guī)則的復雜的密碼,再修改配置項,然后再改成想要的密碼(大小寫字母+數(shù)字+符號)
修改密碼:alter user user() identified by "newPassword"
如果提示密碼強度過低
set global validate_password.policy=0;? # 密碼強度設為最低等級
set global validate_password.length=1;? # 密碼允許最小長度為4,也可以是1
flush privileges;? # 更新授權表,生效
7.設置防火墻
關閉防火墻:systemctl stop firewalld
查看防火墻是否關閉:systemctl status firewalld
禁用防火墻:systemctl disable firewalld
查看Linux是否安裝iptables:systemctl status iptables.service
【如未安裝執(zhí)行:yum install -y iptables】
【安裝iptables-service: yum -y install iptables-services】
修改文件:sudo vi /etc/sysconfig/iptables
不要將如下語句添加到文件末尾,應該添加到22端口這條規(guī)則的下面
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT? # 僅安裝mysql,這條不必執(zhí)行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
保存配置:service iptables save
? ? 重啟防火墻:systemctl restart iptables.service
? ? 設置開機啟動:systemctl enable iptables.service
8.修改允許的連接人
最后進入mysql配置遠程訪問權限(遠程登錄的用戶名為root,密碼為"root")
控制臺執(zhí)行語句1-3:?
create user 'root'@'%' identified by '密碼';
如果語句執(zhí)行失敗,那就drop root,重新create就行
grant all on *.* to 'root'@'%';
alter user 'root'@'%' identified with mysql_native_password by '密碼';
控制臺執(zhí)行語句4: FLUSH PRIVILEGES;