mysql 8 Linux Centos 7.4离线脱机安装配置完整教程

Last modified date

Comments: 0

1.离线脱机安装 Mysql8

首先去官网下载相关组件 https://dev.mysql.com/downloads/mysql/5.5.html?os=31&version=5.1

images大家可以根据操作系统的类型选择相应的安装包,这里我选择的是64位操作系统的安装包。

上传包至服务器目录

解压压缩包,注意这里的压缩包并不是GZIP格式的所以只需用以下命令即可

tar -xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar 

解压后我们看到会有10个安装包,这是安装的是时候一定要注意安装包的安装顺序否则会报错

images下面开始安装

rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm

当在安装

rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm 

会报错

警告:mysql-community-libs-8.0.11-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
mariadb-libs 被 mysql-community-libs-8.0.11-1.el7.x86_64 取代
mariadb-libs is obsoleted by mysql-community-libs-5.7.16-1.el7.x86_64
mariadb-libs is obsoleted by mysql-community-libs-compat-5.7.16-1.el7.x86_64
这个错误是mariadb-libs已经被mysql-community-libs组件放弃了。这里我们只需要删除这个组件即可。
查看已安装的mariadb的组件
rpm -qa|grep mariadb

卸载mariadb的组件

rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

重新再安装mysql-community-libs

rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm 
rpm -ivh mysql-community-libs-compat-8.0.11-1.el7.x86_64.rpm

安装mysql-client

rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm 

安装embedded

rpm -ivh mysql-community-embedded-compat-8.0.11-1.el7.x86_64.rpm

安装debuginfo

rpm -ivh mysql-community-minimal-debuginfo-8.0.11-1.el7.x86_64.rpm

最后安装mysql的服务端

rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm

启动mysql并设置开机启动

systemctl enable mysqld
systemctl start mysqld

至此整个安装过程已经完成

#查看临时密码

grep 'temporary password' /var/log/mysqld.log

用临时密码登录mysql

mysql -u root -p

修改root密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
FLUSH PRIVILEGES; 

 

2.Navicat 连接 Mysql8

2.1 开启mysql远程服务:

 

1
2
3
vim my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password

但是,这个参数只对新授权的用户生效,旧的root密码还是用旧的方式,类似下面这样

1
2
3
4
5
6
7
8
9
10
11
12
13
#先用新客户端登陆
/usr/local/mysql80/bin/mysql -uroot -p123 -P3308 -S /tmp/mysql80.sock
#查看各用户情况
mysql> select Host,User,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| Host      | User             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |
| localhost | mysql.session    | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |
| localhost | mysql.sys        | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |
| localhost | root             | caching_sha2_password | $A$005$.Sf}Q/Jh>3b6CjI5/vMJVDIQbS1dbFWaCVuiby7aX3ZY4lB6/M7Vvny5DUA |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

可以看到plugin是不一样的,密码的加密方式也很明显不一致造成差异.

然后我们再新建一个用户,就可以看到是和以前一样了

1
2
3
4
5
6
7
8
9
10
11
mysql> select Host,User,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| Host      | User             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| %         | sroot            | mysql_native_password | *E56A114692FE0DE073F9A1DD68A00EEB9703F3F1                              |
| localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |
| localhost | mysql.session    | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |
| localhost | mysql.sys        | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |
| localhost | root             | caching_sha2_password | $A$005$.Sf}Q/Jh>3b6CjI5/vMJVDIQbS1dbFWaCVuiby7aX3ZY4lB6/M7Vvny5DUA |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
5 rows in set (0.00 sec)

需要开启远程的连接的话需要新增用户

#先创建一个用户
create user 'sroot'@'%' identified by '123123';
#再进行授权
grant all privileges on *.* to 'sroot'@'%' with grant option;

然后再用sroot 来远程 连接就行了

 

admin

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Post comment