linux安裝mysql8.0及開啟遠端存取

來源:互聯網
上載者:User

標籤:登入   ref   設定   允許   load   alter   修改   分享   rpm包   

第一步:擷取mysql8.0的yum源

    

      進入mysql官網擷取RPM包

                      https://dev.mysql.com/downloads/repo/yum/

         

        點擊下載後,

        

            右鍵複製連結地址     https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

            這個就是。

第二步    下載和安裝mysql源

      未安裝wget指令,需要先安裝。

      yum -y install wget     

      安裝成功之後,下載mysql源

      然後執行 wget https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm

      下載完畢之後,安裝mysql源

      yum -y localinstall mysql80-community-release-el7-11.noarch.rpm 

第三步:線上安裝Mysql

      yum -y install mysql-community-server

      下載的東西比較多 要稍微等會;

 

第四步:啟動Mysql服務

      systemctl start mysqld

 

第五步:設定開機啟動

       systemctl enable mysqld

       systemctl daemon-reload

 

第六步:修改root本地登入密碼

      mysql安裝完成之後,在/var/log/mysqld.log檔案中給root產生了一個臨時的預設密碼。

      [[email protected] ~]# vi /var/log/mysqld.log

      發現有一個臨時密碼  k>Ey>8bCws=s

      此時需要修改為自己的密碼

      

      輸入臨時密碼之後,

      ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘[email protected]‘;  注意:名字必須有大寫字母,數字和特殊符號

第七步:設定允許遠程登入和開啟防火牆

     Mysql預設不允許遠程登入,所以需要開啟遠端存取許可權

     可以先查看user表

     select user,authentication_string,host from user;

     

     預設都是localhost

     update user set host = ‘%‘ where user = ‘root‘;

      

      此時root的host是所有都可以了

      然後開啟防火牆

      

      [[email protected] ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent

      success

      [[email protected] ~]# firewall-cmd --reload

      success

      [[email protected] ~]# 

 

第八步 : 配置預設編碼為utf8

     

      修改/etc/my.cnf設定檔,在[mysqld]下添加編碼配置,如下所示:

      [mysqld]

      character_set_server=utf8

      init_connect=‘SET NAMES utf8‘

      

      

      編輯儲存完 重啟mysql服務;

      [[email protected] ~]# systemctl restart mysqld

      [[email protected] ~]# 

      查看下編碼:

      mysql> show variables like ‘%character%‘;

      

      可以看出已經改為utf8字元了

 

     

     

      

      

      

      

             

 

linux安裝mysql8.0及開啟遠端存取

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.