關於linux-Centos 7下mysql 5.7.9的rpm包的安裝方式

來源:互聯網
上載者:User

標籤:mysql 5.7.9的rpm包的安裝方

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

作業系統:Centos 7.1

mysql資料庫版本:mysql5.7.9

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

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

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

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

2、到mysql的官網下載最新版mysql的rpm集合包:mysql-5.7.9-1.el7.x86_64.rpm-bundle.tar

3、上傳mysql-5.7.9-1.el7.x86_64.rpm-bundle.tar到linux伺服器,並解壓tar包

[[email protected] mysql]# mkdir RPM

[[email protected] mysql]# cd RPM

[[email protected] RPM]# rz -y

rz waiting to receive.

Starting zmodem transfer.  Press Ctrl+C to cancel.

Transferring mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar...

  100%  570950 KB    8274 KB/sec    00:01:09       0 Errors   


[[email protected] RPM]# ls

mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

[[email protected] RPM]# tar -xf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar 

[[email protected] RPM]# ls

mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar                 mysql-community-libs-5.7.18-1.el7.x86_64.rpm

mysql-community-client-5.7.18-1.el7.x86_64.rpm           mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm

mysql-community-common-5.7.18-1.el7.x86_64.rpm           mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm

mysql-community-devel-5.7.18-1.el7.x86_64.rpm            mysql-community-server-5.7.18-1.el7.x86_64.rpm

mysql-community-embedded-5.7.18-1.el7.x86_64.rpm         mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm

mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm  mysql-community-test-5.7.18-1.el7.x86_64.rpm

mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm

4、其中最簡單的安裝mysql-server服務,只需要安裝如下4個軟體包即可,我們可以使用rpm -ivh命令進行安裝

     mysql-community-common-5.7.9-1.el7.x86_64.rpm
     mysql-community-libs-5.7.9-1.el7.x86_64.rpm             --(依賴於common)
     mysql-community-client-5.7.9-1.el7.x86_64.rpm          --(依賴於libs)
     mysql-community-server-5.7.9-1.el7.x86_64.rpm         --(依賴於client、common)

5、接下來是初始化資料庫,我們使用如下幾條命令均可,效果都是一樣的

[[email protected] ~]# mysql_install_db --datadir=/var/lib/mysql   //必須指定datadir,執行後會產生~/.mysql_secret密碼檔案[[email protected] ~]# mysqld --initialize                         //新版的推薦此方法,執行生會在/var/log/mysqld.log產生隨機密碼

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

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

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

[[email protected] ~]# mysql -uroot -p')j#)=uRig4yJ'mysql> set password=password('www.cnblogs.com/5201351');

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欄位


關於linux-Centos 7下mysql 5.7.9的rpm包的安裝方式

聯繫我們

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