卸載MariaDB
CentOS7默認(rèn)安裝MariaDB而不是MySQL,而且yum服務(wù)器上也移除了MySQL相關(guān)的軟件包。因?yàn)镸ariaDB和MySQL可能會(huì)沖突,故先卸載MariaDB。
1、安裝新版mysql之前,我們需要將系統(tǒng)自帶的mariadb-lib卸載
[root@iZwz94qazh62gk5ewl4ei2Z home]# rpm -qa | grep -i mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@iZwz94qazh62gk5ewl4ei2Z home]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
2、到mysql的官網(wǎng)下載最新版mysql的rpm集合包:mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar
3、上傳mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar到linux服務(wù)器,并解壓tar包
[root@iZwz94qazh62gk5ewl4ei2Z home]# mkdir mysql
[root@iZwz94qazh62gk5ewl4ei2Z home]# tar -xf mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar -C mysql
[root@iZwz94qazh62gk5ewl4ei2Z home]# cd mysql
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# ll
total 459492
-rw-r--r-- 1 7155 31415 23618836 Mar 20 17:40 mysql-community-client-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 335496 Mar 20 17:40 mysql-community-common-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 3747352 Mar 20 17:40 mysql-community-devel-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 39086508 Mar 20 17:40 mysql-community-embedded-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 135869292 Mar 20 17:40 mysql-community-embedded-devel-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 2177064 Mar 20 17:40 mysql-community-libs-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 1723180 Mar 20 17:40 mysql-community-libs-compat-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 159060212 Mar 20 17:41 mysql-community-server-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 104881084 Mar 20 17:41 mysql-community-test-5.7.18-1.el6.x86_64.rpm
4、使用rpm -ivh命令進(jìn)行安裝
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# rpm -ivh mysql-community-common-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.18-1.e################################# [100%]
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.18-1.el6################################# [100%]
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# rpm -ivh mysql-community-client-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.18-1.e################################# [100%]
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# rpm -ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.18-1.e################################# [100%]
[root@iZwz94qazh62gk5ewl4ei2Z mysql]#
上面幾個(gè)包有依賴(lài)關(guān)系,執(zhí)行有先后。
使用rpm安裝方式安裝mysql,安裝的路徑如下:
a 數(shù)據(jù)庫(kù)目錄
/var/lib/mysql/
b 配置文件
/usr/share/mysql(mysql.server命令及配置文件)
c 相關(guān)命令
/usr/bin(mysqladmin mysqldump等命令)
d 啟動(dòng)腳本
/etc/rc.d/init.d/(啟動(dòng)腳本文件mysql的目錄)
e /etc/my.conf
5、 數(shù)據(jù)庫(kù)初始化
為了保證數(shù)據(jù)庫(kù)目錄為與文件的所有者為 mysql 登陸用戶(hù),如果你的linux系統(tǒng)是以 root 身份運(yùn)行 mysql 服務(wù),需要執(zhí)行下面的命令初始化
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# mysqld --initialize --user=mysql
如果是以 mysql 身份登錄運(yùn)行,則可以去掉 --user 選項(xiàng)。
另外 --initialize 選項(xiàng)默認(rèn)以“安全”模式來(lái)初始化,則會(huì)為 root 用戶(hù)生成一個(gè)密碼并將該密碼標(biāo)記為過(guò)期,登陸后你需要設(shè)置一個(gè)新的密碼,
而使用 --initialize-insecure
命令則不使用安全模式,則不會(huì)為 root 用戶(hù)生成一個(gè)密碼。
這里演示使用的 --initialize 初始化的,會(huì)生成一個(gè) root 賬戶(hù)密碼,密碼在log文件里,紅色區(qū)域的就是自動(dòng)生成的密碼
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# cat /var/log/mysqld.log
2017-06-05T14:30:52.709474Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-05T14:30:55.590590Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-06-05T14:30:56.000269Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-06-05T14:30:56.109868Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 960c533e-49fb-11e7-91f2-00163e089fd2.
2017-06-05T14:30:56.116186Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-06-05T14:30:56.116777Z 1 [Note] A temporary password is generated for root@localhost: :Wu?2QQutQwj
現(xiàn)在啟動(dòng)mysql數(shù)據(jù)庫(kù)systemctl start mysqld.service
(Centos7特有的啟動(dòng)方式)
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# systemctl start mysqld.service
可以使用下面兩個(gè)命令對(duì)mysql進(jìn)行停止,啟動(dòng)和重啟:
啟動(dòng):
使用 service 啟動(dòng):service mysqld start
使用 mysqld 腳本啟動(dòng):/etc/inint.d/mysqld start
使用 safe_mysqld 啟動(dòng):safe_mysqld
停止:
使用 service 啟動(dòng):service mysqld stop
使用 mysqld 腳本啟動(dòng):/etc/inint.d/mysqld stop
mysqladmin shutdown
重啟:
使用 service 啟動(dòng):service mysqld restart
使用 mysqld 腳本啟動(dòng):/etc/inint.d/mysqld restart
連接數(shù)據(jù)庫(kù)
[root@iZwz94qazh62gk5ewl4ei2Z mysql]# mysql -u root -p
Enter password:
密碼輸入: :Wu?2QQutQwj
修改密碼:
set password = password('你的密碼');
設(shè)置遠(yuǎn)程訪問(wèn)
grant all privileges on *.* to 'root' @'%' identified by '123456';
flush privileges;
設(shè)置mysql開(kāi)機(jī)啟動(dòng)
加入到系統(tǒng)服務(wù):
自動(dòng)啟動(dòng):
查詢(xún)列表:
說(shuō)明:都沒(méi)關(guān)閉(off)時(shí)是沒(méi)有自動(dòng)啟動(dòng)。
以上所述是小編給大家介紹的阿里云 Centos7.3安裝mysql5.7.18 rpm安裝教程,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
您可能感興趣的文章:- centos7.2.1511安裝jdk1.8.0_151及mysql5.6.38的方法
- centos7安裝mysql5.6的方法
- Centos7安裝 mysql5.6.29 shell腳本
- centos7環(huán)境下源碼安裝mysql5.7.16的方法詳解
- Centos7.3下mysql5.7.18安裝并修改初始密碼的方法
- Centos7安裝和配置Mysql5.7
- centos7利用yum安裝lnmp的教程(linux+nginx+php7.1+mysql5.7)
- Centos7使用yum安裝Mysql5.7.19的詳細(xì)步驟
- Linux下Centos7安裝Mysql5.7.19的詳細(xì)教程
- CentOS7服務(wù)器中apache、php7以及mysql5.7的安裝配置代碼
- centos7使用rpm安裝mysql5.7的教程圖解
- centos7環(huán)境下二進(jìn)制安裝包安裝 mysql5.6的方法詳解