關於linux下mysql 5.7.x資料庫的yum的安裝方法

來源:互聯網
上載者:User

標籤:

環境介紹>>>>>>>>>>>>>>>>>>

作業系統:Centos 7.1

mysql資料庫版本:mysql5.7.9

mysql官方網站:http://www.mysql.com

---------------------------------------------

1、安裝新版mysql之前,我們需要將系統內建的mariadb-lib卸載

[[email protected]5201351 ~]# rpm -qa|grep mariadbmariadb-libs-5.5.41-2.el7_0.x86_64[[email protected]5201351 ~]# rpm -e mariadb-libs-5.5.41-2.el7_0.x86_64 --nodeps

2、到mysql的官網下載最新版mysql的yum倉庫檔案,到筆者截稿時最新yum倉庫檔案為:mysql57-community-release-el7-7.noarch.rpm

3、上傳mysql57-community-release-el7-7.noarch.rpm到linux伺服器,並使用rpm命令進行安裝,如所示:

4、我們使用yum方式安裝mysql-server資料庫服務時,只需要安裝,yum會自己解決所需的依賴問題

[[email protected]5201351 ~]# yum install mysql-community-server.x86_64 -y           //yum安裝mysql-community-server服務                              …… …… …… ……省略部分輸出…… …… …… ……Installed:  mysql-community-libs.x86_64 0:5.7.9-1.el7            mysql-community-libs-compat.x86_64 0:5.7.9-1.el7  mysql-community-server.x86_64 0:5.7.9-1.el7                    Dependency Installed:  mysql-community-client.x86_64 0:5.7.9-1.el7           mysql-community-common.x86_64 0:5.7.9-1.el7Replaced:  mariadb-libs.x86_64 1:5.5.41-2.el7_0Complete!

5、接下來是初始化資料庫,我們使用如下兩種方法均可,效果都是一樣的

[[email protected]5201351 ~]# mysql_install_db --datadir=/var/lib/mysql   //必須指定datadir,執行後會產生~/.mysql_secret密碼檔案2015-10-27 00:20:30 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize[[email protected]5201351 ~]# mysqld --initialize                         //新版的推薦此方法,執行生會在/var/log/mysqld.log產生隨機密碼

6、更改mysql資料庫目錄的所屬使用者及其所屬組,然後啟動mysql資料庫

[[email protected]5201351 ~]# chown mysql:mysql /var/lib/mysql -R[[email protected]5201351 ~]# systemctl start mysqld.service            //啟動mysql資料庫服務

7、根據第5步中的密碼登入到mysql,更改root使用者的密碼,新版的mysql在第一次登入後更改密碼前是不能執行任何命令的

[[email protected] ~]# mysql -uroot -p‘g3OK;GgJsT&p‘mysql> select version();ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql> set password for ‘root‘@‘localhost‘=password(‘www.cnblogs.com/5201351‘);mysql> select version();+-----------+| version() |+-----------+| 5.7.9 |+-----------+1 row in set (0.00 sec)mysql>

8、最後我們還可以根據實際情況建立使用者,及作許可權分配

mysql> create user ‘root‘@‘192.168.100.2‘ identified by ‘QQ5201351‘; mysql> GRANT ALL PRIVILEGES ON dbname.* to ‘root‘@‘192.168.100.2‘;mysql> flush privileges

==============================================

最後需要特別提醒注意的一點是,新版的mysql資料庫下的user表中已經沒有Password欄位了,

而是將加密後的使用者密碼儲存於authentication_string欄位

 

尊重別人的勞動成果 轉載請務必註明出處:http://www.cnblogs.com/5201351/p/4912614.html

關於linux下mysql 5.7.x資料庫的yum的安裝方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.