《Mysql應(yīng)用CentOS 7下使用RPM安裝mysql5.7.13》要點(diǎn):
本文介紹了Mysql應(yīng)用CentOS 7下使用RPM安裝mysql5.7.13,希望對您有用。如果有疑問,可以聯(lián)系我們。
0、環(huán)境
MYSQL數(shù)據(jù)庫
本文操作系統(tǒng): CentOS 7.2.1511 x86_64
MySQL 版本: 5.7.13
MYSQL數(shù)據(jù)庫
1、卸載系統(tǒng)自帶的 mariadb-lib
MYSQL數(shù)據(jù)庫
[root@centos-linux ~]# rpm -qa|grep mariadb mariadb-libs-5.5.44-2.el7.centos.x86_64 [root@centos-linux ~]# rpm -e mariadb-libs-5.5.44-2.el7.centos.x86_64 --nodeps
2、下載 rpm 安裝包
MYSQL數(shù)據(jù)庫
去官網(wǎng)找到最新的 rpm 集合包.現(xiàn)在最新的是 mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar
復(fù)制其下載地址,在服務(wù)器下載 (或者本地下載了上傳至服務(wù)器).
MYSQL數(shù)據(jù)庫
然后解壓
MYSQL數(shù)據(jù)庫
[root@centos-linux ~]# ls mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar [root@centos-linux ~]# tar xvf mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar mysql-community-test-5.7.13-1.el7.x86_64.rpm mysql-community-embedded-5.7.13-1.el7.x86_64.rpm mysql-community-embedded-compat-5.7.13-1.el7.x86_64.rpm mysql-community-server-5.7.13-1.el7.x86_64.rpm mysql-community-client-5.7.13-1.el7.x86_64.rpm mysql-community-common-5.7.13-1.el7.x86_64.rpm mysql-community-server-minimal-5.7.13-1.el7.x86_64.rpm mysql-community-embedded-devel-5.7.13-1.el7.x86_64.rpm mysql-community-devel-5.7.13-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.13-1.el7.x86_64.rpm mysql-community-libs-5.7.13-1.el7.x86_64.rpm mysql-community-minimal-debuginfo-5.7.13-1.el7.x86_64.rpm
3、安裝
依次執(zhí)行(幾個(gè)包有依賴關(guān)系,所以執(zhí)行有先后)下面命令安裝
MYSQL數(shù)據(jù)庫
[root@centos-linux ~]# rpm -ivh mysql-community-common-5.7.13-1.el7.x86_64.rpm [root@centos-linux ~]# rpm -ivh mysql-community-libs-5.7.13-1.el7.x86_64.rpm [root@centos-linux ~]# rpm -ivh mysql-community-client-5.7.13-1.el7.x86_64.rpm [root@centos-linux ~]# rpm -ivh mysql-community-server-5.7.13-1.el7.x86_64.rpm
4、數(shù)據(jù)庫初始化
MYSQL數(shù)據(jù)庫
在 *nix 系統(tǒng)中,為了保證數(shù)據(jù)庫目錄為與文件的所有者為 mysql 登陸用戶,如果你是以 root 身份運(yùn)行 mysql 服務(wù),需要執(zhí)行下面的命令初始化
mysqld --initialize --user=mysql
如果是以 mysql 身份運(yùn)行,則可以去掉 --user 選項(xiàng).
另外 --initialize 選項(xiàng)默認(rèn)以“平安”模式來初始化,則會(huì)為 root 用戶生成一個(gè)密碼并將該密碼標(biāo)記為過期,登陸后你需要設(shè)置一個(gè)新的密碼,而使用 --initialize-insecure 命令則不使用平安模式,則不會(huì)為 root 用戶生成一個(gè)密碼.
這里演示使用的 --initialize 初始化的,會(huì)生成一個(gè) root 賬戶密碼,密碼在log文件里
MYSQL數(shù)據(jù)庫
MYSQL數(shù)據(jù)庫
上圖里的最后一行則給出了生成的暗碼,現(xiàn)在就可以啟動(dòng)數(shù)據(jù)庫了,然后使用上面的暗碼登陸.
MYSQL數(shù)據(jù)庫
[root@centos-linux ~]# systemctl start mysqld [root@centos-linux ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.13 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
5、修改 root 暗碼
MYSQL數(shù)據(jù)庫
該暗碼被標(biāo)記為過期了,如果想正常使用還需要修改暗碼MYSQL數(shù)據(jù)庫
mysql> show databases; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
以前的 password()函數(shù)將會(huì)被拋棄,官方建議使用下面的命令來修改暗碼
MYSQL數(shù)據(jù)庫
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
同時(shí),如果你設(shè)置的暗碼過于簡單也會(huì)報(bào)錯(cuò).
MYSQL數(shù)據(jù)庫
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
具體關(guān)于設(shè)置暗碼的規(guī)則,可以看這一篇文章.
這里我們注意設(shè)置暗碼 長度要大于8,同時(shí)要有數(shù)字,大小寫,特殊字符.MYSQL數(shù)據(jù)庫
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所贊助,也希望大家多多支持維易PHP.MYSQL數(shù)據(jù)庫
歡迎參與《Mysql應(yīng)用CentOS 7下使用RPM安裝mysql5.7.13》討論,分享您的想法,維易PHP學(xué)院為您提供專業(yè)教程。
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/11540.html