centos7 安裝 mysql

來源:互聯網
上載者:User

標籤:mysql   centos7   

參考了下面兩個連結

http://www.centoscn.com/mysql/2016/0315/6844.html 連結A

http://www.cnblogs.com/starof/p/4680083.html 連結B


  • centos7不再預設安裝mysql,預設安裝的是mariadb,在命令列裡輸入yum install mysql可以看到提示中顯示要下載mariadb.

  • mariadb的安裝可以參數連結B中的描述

  • 下面是從連結A中擷取的安裝mysql方法.

    在/etc/yum.repos.d目錄中添加一個檔案mysql-community.repo,檔案內容為

  • #Enble to use MySQL 5.6[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/enabled=1gpgcheck=0gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  • 在命令列中輸入,yum install mysql-community-server,即可以安裝mysql,安裝的是mysql5.6,如果系統中安裝了mariadb,mysql的安裝還會將mariadb刪除.

安裝過程中還遇到了一個問題

無法安裝mysql-InvalidGPGKeyfromfile:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

這裡參考了

http://www.2cto.com/database/201701/586216.html 

即將檔案/etc/yum.repos.d/mysql-community.repo中的gpgcheck=1改成gpgcheck=0即可.

這是為什麼上面的檔案與連結A中的檔案內容不同的原因.


啟動mysql

systemctl start  mysqld.service

初次安裝mysql是root賬戶是沒有密碼,需要設定一下,

mysql -h localhost -u root -p進入mysql

設定密碼的時候遇到了問題

mysql> set password for ‘root’@‘localhost’ = password(‘123456‘);ERROR 1133 (42000): Can‘t find any matching row in the user table

解決方案

mysql> grant all on mysql.user to ‘root‘@‘%‘ identified by ‘password‘;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> update mysql.user set password=password(‘123456‘) where user =‘root‘;Query OK, 5 rows affected (0.00 sec)Rows matched: 5  Changed: 5  Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)


本文出自 “夢裡不知身是客” 部落格,請務必保留此出處http://tenfee.blog.51cto.com/6353835/1915007

centos7 安裝 mysql

聯繫我們

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