1.確保Yum環境是否能正常使用
使用yum環境進行軟件的安裝??
yum -y install mysql-server mysql
2.確保軟件包已正常完成安裝
3.設置防火墻和selinux配置
## 關閉防火墻
systemctl stop firewalld## 修該selinux配置
vim /etc/selinux/config
將seliux=enforcing修改為selinux=disable重啟機器
reboot
4.創建安裝目錄
mkdir -p /usr/local/mysqlmkdir -p /usr/local/mysql/data
5.查找目錄路徑
find / -name 'mysql'
6.設置開機自啟動
## 打開mysql服務
systemctl start mysqld.service
## 設置開機自啟動mysql服務
systemctl enable mysqld.service
7.查找MySQ初始密碼
## 切換到日志文件路徑
cat /var/log/mysql/mysqld.log2025-05-29T03:37:37.096070Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
8.登上MySQL之后修改密碼
## 登錄mysql客戶端
mysql -uroot -p## 使用修改密碼sql語句
ALTER USER 'root'@'localhost' identified by '123456';## 刷新配置
FLUSH PRIVILEGES;
9.設置MySQL遠程訪問服務(創建單獨用戶)
創建了一個hahaha用戶,并給予了其相同的超級用戶權利
## 創建hahaha用戶,并設置密碼為666666
create user 'hahaha'@'%' identified with mysql_native_password by '666666';## 給用戶授予權限
grant all privileges on *.* to 'hahaha'@'%';## 刷新配置
flush privileges;
10.使用三方遠程工具連接(Navicat工具)
創建一個新的MySQL連接
連接成功
注意:遇到以下情況問題解決方案
update mysql.user set host='%' where user="root";flush privileges;