CentOS 7 yum安裝配置mysql

來源:互聯網
上載者:User

標籤:service   軟體包   search   源檔案   傳送門   

首先去官網下載要用的yum源 
傳送門:http://dev.mysql.com/downloads/repo/yum/ 
yum源檔案:/home/mysql57-community-release-el7-8.noarch.rpm 
是一個rpm包,如果是Gnome,可以選擇centos7的軟體包安裝程式安裝即可。也可以用命令的方式安裝:

rpm -ivh /home/mysql57-community-release-el7-8.noarch.rpm

使用yum search mysql尋找與mysql有關的包 
mysql-community-server.x86_64 
mysql-community-client.x86_64 
64位系統安裝這兩個包就可以了

sudo yum install mysql-community-server.x86_64 mysql-community-client.x86_64

安裝完成後

650) this.width=650;" src="/img/fz.gif" alt="複製代碼" style="margin:0px;padding:0px;border:none;" />

service restart mysqld[[email protected] applications]$ mysql -u rootERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)[[email protected] applications]$ service mysqld restartRedirecting to /bin/systemctl restart  mysqld.service[[email protected] applications]$ mysql -urootERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

650) this.width=650;" src="/img/fz.gif" alt="複製代碼" style="margin:0px;padding:0px;border:none;" />

mysql-5.7之後為了加強資料庫的安全性,增加了一個隨機性密碼,如果正常安裝成功後,會有提示說隨機性密碼已經產生並儲存在/root/.mysql_secret,於是我看了看

[[email protected] ~]# cat /root/.mysql_secretcat: /root/.mysql_secret: 沒有那個檔案或目錄[[email protected] ~]#

沒有目錄,頭痛,因為是linux小白,最後求助別人

“mysql5.7在密碼管理這塊有了改變,密碼在初始化的時候會寫到mysql的錯誤記錄檔中,你可以通過grep -i password命令對記錄檔進行過濾”

補充:/var/log/messages目錄下可能有mysqld.log.在這個檔案裡搜尋/password也可以。 

終於找到密碼,成功進入mysql,進入首先要修改密碼

alter user ‘root‘@‘localhost‘ identified by ‘password‘;

密碼強度有要求,上邊的密碼肯定不行

my-default.cnf 在/usr/share/mysql下

修改相應的參數即可


CentOS 7 yum安裝配置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.