centOS 7 安裝mysql

來源:互聯網
上載者:User

標籤:--   預設   idt   start   comment   mysqld   5.7   attr   local   

安裝環境:CentOS7 64位 MINI版,安裝MySQL5.7

1、配置YUM源

在MySQL官網中下載YUM源rpm安裝包:http://dev.mysql.com/downloads/repo/yum/ 

# 下載mysql源安裝包shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm# 安裝mysql源shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm

檢查mysql源是否安裝成功

shell> yum repolist enabled | grep "mysql.*-community.*"

 
看到所示表示安裝成功。 
可以修改vim /etc/yum.repos.d/mysql-community.repo源,改變預設安裝的mysql版本。比如要安裝5.6版本,將5.7源的enabled=1改成enabled=0。然後再將5.6源的enabled=0改成enabled=1即可。改完之後的效果如下所示: 

2、安裝MySQL
shell> yum install mysql-community-server
3、啟動MySQL服務
shell> systemctl start mysqld

查看MySQL的啟動狀態

shell> systemctl status mysqld● mysqld.service - MySQL Server   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)   Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago Main PID: 2888 (mysqld)   CGroup: /system.slice/mysqld.service           └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server...6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
4、開機啟動
shell> systemctl enable mysqldshell> systemctl daemon-reload
5、修改root本地登入密碼

mysql安裝完成之後,在/var/log/mysqld.log檔案中給root產生了一個預設密碼。通過下面的方式找到root預設密碼,然後登入mysql進行修改:

shell> grep ‘temporary password‘ /var/log/mysqld.log

shell> mysql -uroot -p                       //登入mysql

centOS 7 安裝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.