centOS 7 安裝mysql
阿新 • • 發佈:2018-02-28
reload -- centos wid moni 默認 blog vsp download
安裝環境: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.pid
6月 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 mysqld
shell> 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