[root@localhost soft]# rpm -qa | grep -i mysql
MySQL-python-1.2.3-11.el7.x86_64
php-mysql-5.4.16-36.1.el7_2.1.x86_64
[root@localhost soft]# yum -y remove MySQL-python
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 MySQL-python.x86_64.0.1.2.3-11.el7 将被 删除
--> 解决依赖关系完成
依赖关系解决
=============================================================================================================================
Package 架构 版本 源 大小
=============================================================================================================================
正在删除:
MySQL-python x86_64 1.2.3-11.el7 @/MySQL-python-1.2.3-11.el7.x86_64 231 k
事务概要
=============================================================================================================================
移除 1 软件包
安装大小:231 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : MySQL-python-1.2.3-11.el7.x86_64 1/1
验证中 : MySQL-python-1.2.3-11.el7.x86_64 1/1
删除:
MySQL-python.x86_64 0:1.2.3-11.el7
完毕!
[root@localhost soft]# yum -y remove php-mysql
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 php-mysql.x86_64.0.5.4.16-36.1.el7_2.1 将被 删除
--> 解决依赖关系完成
依赖关系解决
=============================================================================================================================
Package 架构 版本 源 大小
=============================================================================================================================
正在删除:
php-mysql x86_64 5.4.16-36.1.el7_2.1 @updates 232 k
事务概要
=============================================================================================================================
移除 1 软件包
安装大小:232 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : php-mysql-5.4.16-36.1.el7_2.1.x86_64 1/1
验证中 : php-mysql-5.4.16-36.1.el7_2.1.x86_64 1/1
删除:
php-mysql.x86_64 0:5.4.16-36.1.el7_2.1
完毕!
[root@localhost soft]# groupadd mysql
[root@localhost soft]# useradd -r -g mysql mysql
[root@localhost soft]# yum install mysql-community-{client,common,libs}-*
已加载插件:fastestmirror, langpacks
正在检查 mysql-community-client-5.7.12-1.el7.x86_64.rpm: mysql-community-client-5.7.12-1.el7.x86_64
mysql-community-client-5.7.12-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-common-5.7.12-1.el7.x86_64.rpm: mysql-community-common-5.7.12-1.el7.x86_64
mysql-community-common-5.7.12-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-libs-5.7.12-1.el7.x86_64.rpm: mysql-community-libs-5.7.12-1.el7.x86_64
mysql-community-libs-5.7.12-1.el7.x86_64.rpm 将被安装
正在检查 mysql-community-libs-compat-5.7.12-1.el7.x86_64.rpm: mysql-community-libs-compat-5.7.12-1.el7.x86_64
mysql-community-libs-compat-5.7.12-1.el7.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.47-1.el7_2 将被 取代
---> 软件包 mariadb-libs.x86_64.1.5.5.47-1.el7_2 将被 取代
---> 软件包 mysql-community-client.x86_64.0.5.7.12-1.el7 将被 舍弃
---> 软件包 mysql-community-common.x86_64.0.5.7.12-1.el7 将被 安装
---> 软件包 mysql-community-libs.x86_64.0.5.7.12-1.el7 将被 舍弃
---> 软件包 mysql-community-libs-compat.x86_64.0.5.7.12-1.el7 将被 舍弃
--> 解决依赖关系完成
依赖关系解决
=============================================================================================================================
Package 架构 版本 源 大小
=============================================================================================================================
正在安装:
mysql-community-client x86_64 5.7.12-1.el7 /mysql-community-client-5.7.12-1.el7.x86_64 106 M
替换 mariadb.x86_64 1:5.5.47-1.el7_2
mysql-community-common x86_64 5.7.12-1.el7 /mysql-community-common-5.7.12-1.el7.x86_64 2.5 M
mysql-community-libs x86_64 5.7.12-1.el7 /mysql-community-libs-5.7.12-1.el7.x86_64 9.5 M
替换 mariadb-libs.x86_64 1:5.5.47-1.el7_2
mysql-community-libs-compat x86_64 5.7.12-1.el7 /mysql-community-libs-compat-5.7.12-1.el7.x86_64 9.2 M
替换 mariadb-libs.x86_64 1:5.5.47-1.el7_2
事务概要
=============================================================================================================================
安装 4 软件包
总计:127 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql-community-common-5.7.12-1.el7.x86_64 1/6
正在安装 : mysql-community-libs-5.7.12-1.el7.x86_64 2/6
正在安装 : mysql-community-client-5.7.12-1.el7.x86_64 3/6
正在安装 : mysql-community-libs-compat-5.7.12-1.el7.x86_64 4/6
正在删除 : 1:mariadb-5.5.47-1.el7_2.x86_64 5/6
正在删除 : 1:mariadb-libs-5.5.47-1.el7_2.x86_64 6/6
验证中 : mysql-community-client-5.7.12-1.el7.x86_64 1/6
验证中 : mysql-community-common-5.7.12-1.el7.x86_64 2/6
验证中 : mysql-community-libs-5.7.12-1.el7.x86_64 3/6
验证中 : mysql-community-libs-compat-5.7.12-1.el7.x86_64 4/6
验证中 : 1:mariadb-5.5.47-1.el7_2.x86_64 5/6
验证中 : 1:mariadb-libs-5.5.47-1.el7_2.x86_64 6/6
已安装:
mysql-community-client.x86_64 0:5.7.12-1.el7 mysql-community-common.x86_64 0:5.7.12-1.el7
mysql-community-libs.x86_64 0:5.7.12-1.el7 mysql-community-libs-compat.x86_64 0:5.7.12-1.el7
替代:
mariadb.x86_64 1:5.5.47-1.el7_2 mariadb-libs.x86_64 1:5.5.47-1.el7_2
完毕!
[root@localhost soft]#
[root@localhost soft]# rpm -qa | grep -i mysql
mysql-community-libs-compat-5.7.12-1.el7.x86_64
mysql-community-common-5.7.12-1.el7.x86_64
mysql-community-libs-5.7.12-1.el7.x86_64
mysql-community-client-5.7.12-1.el7.x86_64
[root@localhost soft]# pwd
/soft
[root@localhost soft]# ll
总用量 1106888
-rwxr-xr-x. 1 root root 566722560 5月 21 10:25 mysql-5.7.12-1.el7.x86_64.rpm-bundle.tar
-rwxr-xr-x. 1 7155 31415 24991304 3月 29 15:38 mysql-community-client-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 276736 3月 29 15:38 mysql-community-common-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 3786120 3月 29 15:38 mysql-community-devel-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 45150068 3月 29 15:38 mysql-community-embedded-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 23829224 3月 29 15:38 mysql-community-embedded-compat-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 124953868 3月 29 15:39 mysql-community-embedded-devel-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 2237968 3月 29 15:39 mysql-community-libs-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 2115948 3月 29 15:39 mysql-community-libs-compat-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 51016520 3月 29 15:40 mysql-community-minimal-debuginfo-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 158252992 3月 29 15:40 mysql-community-server-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 13998408 3月 29 15:41 mysql-community-server-minimal-5.7.12-1.el7.x86_64.rpm
-rwxr-xr-x. 1 7155 31415 116098332 3月 29 15:41 mysql-community-test-5.7.12-1.el7.x86_64.rpm
[root@localhost soft]# yum install mysql-community-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.neusoft.edu.cn
* extras: mirrors.yun-idc.com
* updates: mirrors.tuna.tsinghua.edu.cn
没有可用软件包 mysql-community-server。
错误:无须任何处理
[root@localhost soft]# rpm -ivh mysql-community-server-
mysql-community-server-5.7.12-1.el7.x86_64.rpm mysql-community-server-minimal-5.7.12-1.el7.x86_64.rpm
[root@localhost soft]# rpm -ivh mysql-community-server-5.7.12-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.12-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-5.7.12-1.e################################# [100%]
[root@localhost soft]# rpm -ivh mysql-community-devel-5.7.12-1.el7.x86_64.rpm
警告:mysql-community-devel-5.7.12-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-devel-5.7.12-1.el################################# [100%]
[root@localhost soft]# rpm -qa | grep -i mysql
mysql-community-libs-compat-5.7.12-1.el7.x86_64
mysql-community-common-5.7.12-1.el7.x86_64
mysql-community-server-5.7.12-1.el7.x86_64
mysql-community-libs-5.7.12-1.el7.x86_64
mysql-community-devel-5.7.12-1.el7.x86_64
mysql-community-client-5.7.12-1.el7.x86_64
[root@localhost soft]#
[root@localhost soft]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@localhost soft]# mysql -u mysql -p -S /var/lib/mysql/mysql.sock
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@localhost soft]# chown -R mysql:mysql /var/lib/mysql
[root@localhost soft]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@localhost soft]# ps -el | grep mysqld
1 S 1001 6503 1 1 80 0 - 466720 poll_s ? 00:00:00 mysqld
[root@localhost soft]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost soft]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost soft]# mysqladmin -u root flush-privileges password "newpassword"
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
[root@localhost soft]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@localhost soft]# grep 'temporary password' /var/log/mysqld.log
2016-05-21T04:01:25.452939Z 1 [Note] A temporary password is generated for root@localhost: iM.OOzNGO3gG(临时密码)
[root@localhost soft]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.12
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> ALTER USER 'root'@'localhost' IDENTIFIED BY '1qaz@WSX';
Query OK, 0 rows affected (0.10 sec)