天天看點

【軟體安裝記錄篇】本地虛拟機Centos7快速安裝MySQL

本地虛拟機centos7快速安裝mysql

安裝

采用Installing MySQL on Linux Using the MySQL Yum Repository的方式進行安裝。
  1. 首先下載下傳伺服器版本對應的rpm檔案,下載下傳位址:[連結](https://dev.mysql.com/downloads/repo/yum/),下載下傳完成之後上傳到自己的某個檔案夾中。

  2. 安裝rpm檔案:sudo yum install mysql80-community-release-el7-{version-number}.noarch.rpm;

  3. 安裝社群版資料庫:yum install mysql-community-server;

  4. 啟動Mysql:service mysqld restart;
           

修改密碼

1. 檢視初始化密碼:grep 'temporary password' /var/log/mysqld.log;,這個log中記錄着初始化密碼。

  2. 用初始化密碼進行登入到MySQL:mysql -uroot -p;。

  3. 設定修改之後的密碼:ALTER USER 'root'@'localhost' IDENTIFIED BY 'kdaDDy123!';注意此處的密碼設定有所要求,必須是數字外加大小寫外加特殊字元組成,否則會報設定失敗Your password does not satisfy the current policy requirements。
           

遠端連接配接

1. 建立遠端連接配接的使用者:create user  'ktdaddy'@'%' identified with mysql_native_password by '1eeLjihao!';

  2. 授權遠端使用者:grant all on *.* to 'ktdaddy' @'%';

  3. 重新整理權限:flush privileges;

  4. 嘗試用遠端工具測試連接配接。登入名為ktdaddy,密碼為:1eeLjihao!。如果此時發現依舊無法連接配接,那麼要考慮是否是防火牆沒有關閉。

  5. 輸入指令systemctl status firewalld.service;,如果發現防火牆為active(running),那麼此時防火牆為打開狀态。此時關閉防火牆。

  6. 臨時關閉防火牆systemctl stop firewalld.service;,然後可以用指令systemctl status firewalld.service檢查防火牆的狀态。

  7. 若要永久關閉防火牆systemctl disable firewalld.service;。

  8. 再次測試連接配接資料庫,則連接配接成功!           

熱愛技術,熱愛産品,熱愛生活,一個懂技術,懂産品,懂生活的程式員~

更多精彩内容,可以關注公衆号“程式員老貓”。

一起讨論技術,探讨一下點子,研究研究賺錢!

繼續閱讀