登錄官網(wǎng)下載Fedora28的資源庫并安裝

Fedora的mysql資源庫.png
- 安裝MySQL服務(wù)器
sudo dnf install mysql-community-server
通過免密登錄方式修改MySQLroot用戶的密碼
- 修改MySQL的登錄設(shè)置
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf # 在文件末尾加上一句:skip-grant-tables,然后保存退出
- 啟動MySQL
/etc/init.d/mysql start
- 登錄MySQL
mysql -u root -p # 提示輸入密碼直接回車免密碼登錄
- 更新用戶root的登錄密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'; # 密碼必須包含字母大小寫,數(shù)字,特殊字符,否則會報(bào)錯(cuò)
- 執(zhí)行完上面的語句后會提示如下錯(cuò)誤
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
- 只需執(zhí)行刷新語句后再重復(fù)一遍更新密碼的語句就不會再報(bào)錯(cuò)誤
flush privileges;
- 刪除上面在my.cnf文件中添加的一句內(nèi)容
- 重啟MySQL
/etc/init.d/mysql stop
/etc/nit.d/mysql start
- 嘗試密碼登錄mysql測試是否更改成功