Centos7 yum安裝MySQL5.7

MySQL5.7 增加用戶,新建數(shù)據(jù)庫,授權(quán),遠程訪問

1.安裝yum repo

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
然后進行repo的安裝
rpm -ivh mysql57-community-release-el7-9.noarch.rpm

2.安裝MySQL5.7(如果遇到錯誤,參考2.1,2.2)

使用yum命令

yum install mysql-server

2.1可能會遇到報錯

安裝過程中可能出現(xiàn)的報錯

mariadb101u-common conflicts with mysql-community-common-5.7.24-1.el7.x86_64
mariadb101u-config conflicts with mysql-community-server-5.7.24-1.el7.x86_64
沖突.png

上面的mariadb101u和mysql沖突了,那么卸載掉即可,注意看一共有幾個errors

2.2處理卸載沖突的軟件

卸載的版本要和Erros地方對應起來,例如

 rpm -e mariadb101u-config-10.1.35-1.ius.centos7.x86_64 --nodeps

3.設置無密碼啟動

  • 編輯配置MySQL文件
vim /etc/my.cnf
  • 在配置文件最后加入無密碼啟動的配置
skip-grant-tables 
  • 重啟MySQL服務
systemctl restart mysqld.service
或者  systemctl restart  mysqld
service restart mysql可能是不行的

4.修改MySQL root密碼

  • 無密碼進入MySQL
mysql -uroot;
  • 修改root密碼,例如:
use mysql;
update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';

需要注意的是,MySQL5.7中,已經(jīng)不再用password這個字段.而是authentication_string
可以通過查看mysql庫中的user表看到:

mysql庫user表的表結(jié)構(gòu)

5.去掉無密碼啟動的配置

  • 退出MySQL
exit;
  • 編輯MySQL配置文件,去掉第五步中的
skip-grant-tables 
  • 重啟MySQL
systemctl restart mysqld.service
  • 用密碼登錄MySQL
mysql -uroot -p
搞定~~.png

MySQL5.7 增加用戶,新建數(shù)據(jù)庫,授權(quán),遠程訪問

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容