MySQL安装中问题整合(Redhat下MySQL5.6和5.7)

目录

1、安装前准备

2、解压

3、安装

4、安装中出现的问题

5、修改密码

6、连接Navicat

 


 

1、安装前准备

安装之前确保删除系统自带的mysql和mariadb

    # rpm -qa | grep mysql
    # rpm -e --nodeps  mysql-xxxx
    # rpm -qa | grep mariadb
    # rpm -e --nodeps mariadb-xxxx

(ps:--nodeps就是安装时不检查依赖关系)

2、解压

解压安装包(我发现MySQL5.6只需要下载 MySQL-serve和 MySQL-client,所以可以跳过这一步)

#tar -xvf mysql-xxxx.rpm-bundle.tar

3、安装

这些文件需要一起执行,因为有循环依赖包,这样可以避免很多问题

<这是MySQL5.6版本的>

# rpm -ivh MySQL-server-5.6.32-1.el7.x86_64.rpm
# rpm -ivh MySQL-client-5.6.32-1.el7.x86_64.rpm 

<这是MySQL5.7版本的>

!!!注意,按照下面的顺序执行

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

mysql-community-libs-5.7.9-1.el7.x86_  64.rpm

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

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

#sudo rpm -ivh --force mysql-community-common-5.7.9-1.el7.x86_64.rpm mysql-community-libs-5.7.9-1.el7.x86_  64.rpm mysql-community-client-5.7.9-1.el7.x86_64.rpm mysql-community-server-5.7.9-1.el7.x86_64.rpm 

(ps:--force就是强制安装)

4、安装中出现的问题

要是安装完成还是有问题(一般是出现一下的问题)

<这是MySQL5.6版本的>

[root@localhost MySQL5.6.32]# rpm -ivh MySQL-server-5.6.32-1.el7.x86_64.rpm 
警告:MySQL-server-5.6.32-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
	/usr/bin/perl 被 MySQL-server-5.6.32-1.el7.x86_64 需要
	libaio.so.1()(64bit) 被 MySQL-server-5.6.32-1.el7.x86_64 需要
	libaio.so.1(LIBAIO_0.1)(64bit) 被 MySQL-server-5.6.32-1.el7.x86_64 需要
	libaio.so.1(LIBAIO_0.4)(64bit) 被 MySQL-server-5.6.32-1.el7.x86_64 需要
	net-tools 被 MySQL-server-5.6.32-1.el7.x86_64 需要

这样就是意味着你需要yum这些包

比如我的这种情况就是

yum -y install perl libaio net-tools

但是即使这样可能也会遇到问题,如下图所示

[root@localhost MySQL5.6.32]# rpm -ivh MySQL-server-5.6.32-1.el7.x86_64.rpm 
警告:MySQL-server-5.6.32-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
        file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
        file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.32-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64

查资料显示是需要yum一些包

# yum install -y perl perl-devel
# yum -y install autoconf

即使这样还是有问题,如下图所示

[root@localhost MySQL5.6.32]# rpm -ivh MySQL-server-5.6.32-1.el7.x86_64.rpm 
警告:MySQL-server-5.6.32-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
	软件包 MySQL-server-5.6.32-1.el7.x86_64 已经安装
[root@localhost MySQL5.6.32]# rpm -ivh MySQL-client-5.6.32-1.el7.x86_64.rpm 
警告:MySQL-client-5.6.32-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-client-5.6.32-1.el7        ################################# [100%]
[root@localhost MySQL5.6.32]# service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.pid).

查资料,是说需要perl-Data-Dumper,于是继续yum

# yum install -y perl-Data-Dumper

再次启动MySQL就成功了

[root@localhost MySQL5.6.32]# service mysql start
Starting MySQL. SUCCESS! 

<这是MySQL5.7版本的>

警告:mysql-community-common-5.7.9-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
	/usr/bin/perl 被 mysql-community-server-5.7.9-1.el7.x86_64 需要
	libaio.so.1()(64bit) 被 mysql-community-server-5.7.9-1.el7.x86_64 需要
	libaio.so.1(LIBAIO_0.1)(64bit) 被 mysql-community-server-5.7.9-1.el7.x86_64 需要
	libaio.so.1(LIBAIO_0.4)(64bit) 被 mysql-community-server-5.7.9-1.el7.x86_64 需要
	net-tools 被 mysql-community-server-5.7.9-1.el7.x86_64 需要
	perl(Getopt::Long) 被 mysql-community-server-5.7.9-1.el7.x86_64 需要
perl(strict) 被 mysql-community-server-5.7.9-1.el7.x86_64 需要

这样就是意味着你需要yum这些包

比如我的这种情况就是

# yum -y install perl libaio net-tools

然后再安装就可以运行了

[root@localhost MySQL5.7.9]# sudo rpm -ivh --force mysql-community-common-5.7.9-1.el7.x86_64.rpm mysql-community-libs-5.7.9-1.el7.x86_64.rpm mysql-community-client-5.7.9-1.el7.x86_64.rpm mysql-community-server-5.7.9-1.el7.x86_64.rpm 
警告:mysql-community-common-5.7.9-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-common-5.7.9-1.el################################# [ 25%]
   2:mysql-community-libs-5.7.9-1.el7 ################################# [ 50%]
   3:mysql-community-client-5.7.9-1.el################################# [ 75%]
   4:mysql-community-server-5.7.9-1.el################################# [100%]
[root@localhost MySQL5.7.9]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service

5、修改密码

<这是MySQL5.6版本的>

[root@localhost MySQL5.6.32]# service mysql start
Starting MySQL. SUCCESS! 
[root@localhost MySQL5.6.32]# passwd mysql
更改用户 mysql 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。

接着# service mysql stop

# service mysql stop

从后台进入修改root的密码

[root@localhost MySQL5.6.32]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 9138
[root@localhost MySQL5.6.32]# 200917 19:40:25 mysqld_safe Logging to '/var/lib/mysql/localhost.err'.
200917 19:40:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.32 MySQL Community Server (GPL)

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> UPDATE user SET password=PASSWORD('xxx') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql>  FLUSH PRIVILEGES;#更新完密码需要刷新,新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

然后再次开启mysql修改密码

[root@localhost MySQL5.6.32]# service mysql restart
Shutting down MySQL..200917 19:40:58 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.pid ended
 SUCCESS! 
Starting MySQL. SUCCESS! 
[1]+  完成                  mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[root@localhost MySQL5.6.32]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.32 MySQL Community Server (GPL)

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> SET PASSWORD = PASSWORD('xxx');
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

<这是MySQL5.7版本的>

和上述操作差不多,就是需要把mysql换成mysqld

但是再从后台进入mysql修改密码时爆出了下面的错误

[root@localhost MySQL5.7.9]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 11345
[root@localhost MySQL5.7.9]# -bash: mysqld_safe: 未找到命令

发现是需要把mysqld_safe换成mysqld,再次尝试

[root@localhost MySQL5.7.9]# mysqld --user=mysql --skip-grant-tables --skip-networking &
[1] 11347
[root@localhost MySQL5.7.9]# mysqld --user=mysql --skip-grant-tables --skip-networking &
[2] 11375
[root@localhost MySQL5.7.9]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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.7修改密码时需要注意用下面的命令

 update mysql.user set authentication_string=password('xxx') where user='root' ;

mysql> update mysql.user set authentication_string=password('xxx') where user='root' ;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

然后再次开启mysql修改密码

[root@localhost MySQL5.6.32]# service mysql restart
Shutting down MySQL..200917 19:40:58 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.pid ended
 SUCCESS! 
Starting MySQL. SUCCESS! 
[1]+  完成                  mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[root@localhost MySQL5.6.32]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.32 MySQL Community Server (GPL)

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> SET PASSWORD = PASSWORD('xxx');
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

6、连接Navicat

关闭防火墙,连接Navicat

# systemctl stop firewalld

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值