CentOs7.4安装Mysql5.7

一.下载安装包

目录

一.下载安装包

1.1官网下载

1.2选择好版本

1.3下载rpm包

二.开始安装

2.1按上面顺序安装rpm包

2.2启动mysql服务

2.3登陆修改密码

三.遇到的问题


 

1.1官网下载

https://dev.mysql.com/downloads/mysql/

CentOs7.4安装Mysql5.7

1.2选择好版本

CentOs7.4安装Mysql5.7

 

 

1.3下载rpm包

CentOs7.4安装Mysql5.7

 

mysql-community-common-5.7.22-1.el7.x86_64.rpm

mysql-community-libs-5.7.22-1.el7.x86_64.rpm

mysql-community-client-5.7.22-1.el7.x86_64.rpm

mysql-community-server-5.7.22-1.el7.x86_64.rpm

下载这4个包即可,如需要其他工具请自行下载安装

 

二.开始安装

2.1按上面顺序安装rpm包

[[email protected] ~]# rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm

[[email protected] ~]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm

[[email protected] ~]# rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm

[[email protected] ~]# rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm

 

2.2启动mysql服务

 

[[email protected] ~]# service mysqld start

Redirecting to /bin/systemctl start mysqld.service

 

2.3登陆修改密码

启动后系统自动生成一个密码存储在/var/log/mysqld.log

[[email protected] ~]# grep password /var/log/mysqld.log 

2018-07-18T10:42:45.283629Z 1 [Note] A temporary password is generated for [email protected]: 6q33PelhRK?v

 

[[email protected] ~]# mysql -uroot -p6q33PelhRK?v

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.7.22

 

Copyright (c) 2000, 2018, 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> 

 

成功登陆

mysql> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

意思是需要修改密码

mysql> alter user 'root'@'localhost' identified by '[email protected]';

 

三.遇到的问题

[[email protected] ~]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm

warning: mysql-community-libs-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.22-1.el7.x86_64

mariadb-libs is obsoleted by mysql-community-libs-5.7.22-1.el7.x86_64

 

第二行centos7自带mariadb与mysql冲突,卸载mariadb即可。第一行由于冲突mysql-community-common没有安装成功,卸载mariadb后重新安装即可。

[[email protected] ~]# rpm -qa |grep mariadb

mariadb-libs-5.5.56-2.el7.x86_64

 

[[email protected] ~]# rpm -e mariadb-libs-5.5.56-2.el7.x86_64

error: Failed dependencies:

libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64

libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64

强行卸载

[[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64