MySql 8.0.11安装配置教程

官网地址:https://dev.mysql.com/downloads/mysql/

我这里是RHEL6.5的系统,因此选择RedHat 6 x86,64bit操作系统---下载第一个RPM Bundle即可--mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar。

目前MySQL8.0.11社区版提供了多种多样的安装方式,但是并未发现针对Linux Generic安装包包含的mysql_secure_installation的安装说明。

因此这里使用推荐的RPM安装:

一、mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar解压后有如下7个文件:

-rw-r--r-- 1 root root 28987588 Apr 9 01:06 mysql-community-client-8.0.11-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  672184 Apr 9 01:06 mysql-community-common-8.0.11-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  4443296 Apr 9 01:06 mysql-community-devel-8.0.11-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  2579460 Apr 9 01:06 mysql-community-libs-8.0.11-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  1902676 Apr 9 01:06 mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 395918848 Apr 9 01:07 mysql-community-server-8.0.11-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 49092596 Apr 9 01:07 mysql-community-test-8.0.11-1.el6.x86_64.rpm

然后创建mysql用户:

useradd mysql
passwd mysql

二、安装顺序为:(建议装之前先把之前的mysql相关包全部卸载,rpm -e --nodeps <包名>即可)

[root@python ~]# rpm -ivh mysql-community-common-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-common-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...        ########################################### [100%]
  1:mysql-community-common ########################################### [100%]
[root@python ~]# rpm -ivh mysql-community-libs-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-libs-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...        ########################################### [100%]
  1:mysql-community-libs  ########################################### [100%]
[root@python ~]# rpm -ivh mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...        ########################################### [100%]
  file /usr/lib64/mysql/libmysqlclient.so.16.0.0 from install of mysql-community-libs-compat-8.0.11-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-8.0.1.el6_8.x86_64
  file /usr/lib64/mysql/libmysqlclient_r.so.16.0.0 from install of mysql-community-libs-compat-8.0.11-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-8.0.1.el6_8.x86_64
[root@python ~]# rpm -e --nodeps mysql-libs-5.1.73-8.0.1.el6_8.x86_64
[root@python ~]# rpm -ivh mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...        ########################################### [100%]
  1:mysql-community-libs-co########################################### [100%]
[root@python ~]# rpm -ivh mysql-community-server-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-server-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
  mysql-community-client(x86-64) >= 8.0.0 is needed by mysql-community-server-8.0.11-1.el6.x86_64
[root@python ~]# rpm -ivh mysql-community-client-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-client-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...        ########################################### [100%]
  1:mysql-community-client ########################################### [100%]
[root@python ~]# rpm -ivh mysql-community-server-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-server-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...        ########################################### [100%]
  1:mysql-community-server ########################################### [100%]
[root@python ~]# rpm -ivh mysql-community-devel-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-devel-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...        ########################################### [100%]
  1:mysql-community-devel ########################################### [100%]
^[[A[root@python ~]# rpm -ivh mysql-community-test-8.0.11-1.el6.x86_64.rpm
warning: mysql-community-test-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
  perl(JSON) is needed by mysql-community-test-8.0.11-1.el6.x86_64
--懒的去装perl了,因此测试套件就不装了。

三、安装完毕后相关信息如下:

[root@python ~]# mysql -V
mysql Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL)
[root@python ~]# ll /etc/init.d/mysqld
-rwxr-xr-x 1 root root 7166 Apr 8 16:21 /etc/init.d/mysqld
[root@python ~]# ll /etc/my.cnf --配置文件位置
-rw-r--r-- 1 root root 1188 Apr 8 16:21 /etc/my.cnf

默认的datadir是在/var/lib/mysql/,可以通过修改my.cnf修改,启动命令如下:

[root@python ~]# service mysqld start
Initializing MySQL database:                [ OK ]
Starting mysqld:
[ OK ]

四、发现没密码不能登录,于是添加skip-grant-tables到my.cnf,重启进去重置密码

mysql> alter user root@'localhost' identified by 'mysql';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> exit
Bye

居然不能改。。。于是:

mysql> delete from mysql.user where user='root';
Query OK, 1 row affected (0.10 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create user root@'localhost' identified by 'mysql';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

还是不能改,查看密码复杂度要求:

mysql> show variables like '%pass%';
+----------------------------------------------+-----------------+
| Variable_name                | Value      |
+----------------------------------------------+-----------------+
| caching_sha2_password_auto_generate_rsa_keys | ON       |
| caching_sha2_password_private_key_path    | private_key.pem |
| caching_sha2_password_public_key_path    | public_key.pem |
| default_password_lifetime          | 0        |
| disconnect_on_expired_password        | ON       |
| mysql_native_password_proxy_users      | OFF       |
| password_history               | 0        |
| password_reuse_interval           | 0        |
| report_password               |         |
| sha256_password_auto_generate_rsa_keys    | ON       |
| sha256_password_private_key_path       | private_key.pem |
| sha256_password_proxy_users         | OFF       |
| sha256_password_public_key_path       | public_key.pem |
| validate_password.check_user_name      | ON       |
| validate_password.dictionary_file      |         |
| validate_password.length           | 8        |
| validate_password.mixed_case_count      | 1        |
| validate_password.number_count        | 1        |
| validate_password.policy           | MEDIUM     |
| validate_password.special_char_count     | 1        |
+----------------------------------------------+-----------------+

查看官网https://dev.mysql.com/doc/refman/8.0/en/validate-password-options-variables.html#sysvar_validate_password.policy

发现此值有3个,如下所示:

于是设置为0,然后将validate_password.length设置为4,表示最少需要4字符。之所以设置为4是因为这个参数的值不能小于如下公式的计算结果:

validate_password.number_count
+ validate_password.special_char_count
+ (2 * validate_password.mixed_case_count)

于是继续创建用户,MySQL8.0取消了直接grant创建用户的语法,只能先create user再grant,因此创建root如下:

mysql> create user root@'localhost' identified by 'mysql';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> create user root@'localhost' identified by 'mysql';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'

尼玛...什么玩意儿?

于是去逛了一圈stackoverflow,都说这是一个BUG,于是操作如下:

mysql> drop user root@'localhost';  --是的没错,虽然没有root@'localhost'用户,但你还是要删一遍。
Query OK, 0 rows affected (0.05 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> create user root@'localhost' identified by 'mysql';
Query OK, 0 rows affected (0.03 sec)
mysql> grant all on *.* to root@'localhost' with grant option;
Query OK, 0 rows affected (0.03 sec)

终于改完密码了...去掉参数文件的skip-grant-tables参数,service mysqld restart重启服务。

五、终于设置好密码了,建一个测试用户leo,然后尝试远程连接下吧:

$ mysql -uleo -pmysql -h192.168.1.193
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

我这5.7的mysql工具都连不上,这就尴尬了,查看认证相关参数:

mysql> show variables like '%auth%';
+-------------------------------+-----------------------+
| Variable_name         | Value         |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
1 row in set (0.02 sec)

查看官网发现此值的取值如下:

官网还说此值影响create user不显式指定auth plugin时密码的默认加密算法,卧槽...那岂不是说我之前创建的leo用户使用的是默认的caching_sha2_password认证,查看一下:

mysql> select user,host,plugin from mysql.user;
+------------------+-----------+-----------------------+
| user       | host   | plugin        |
+------------------+-----------+-----------------------+
| leo       | %     | caching_sha2_password |
| mysql.infoschema | localhost | mysql_native_password |
| mysql.session  | localhost | mysql_native_password |
| mysql.sys    | localhost | mysql_native_password |
| root       | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+

完了,全TM完了......

显然不能直接update plugin,因为这可能导致加密的密码无法被正确解密,你所有的密码都会变异,因此除root@'localhost'外全部删掉重建。

首先需要在my.cnf里添加:default_authentication_plugin=mysql_native_password,然后service mysqld restart重启服务:

mysql> drop user leo;
Query OK, 0 rows affected (0.10 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create user leo identified by 'mysql';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all on *.* to leo;
Query OK, 0 rows affected (0.08 sec)

$mysql -V
mysql Ver 14.14 Distrib 5.7.20, for Linux (x86_64) using EditLine wrapper
$ mysql -uleo -pmysql -h192.168.1.193
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 16
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2017, 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 8.0.11安装配置教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!

(0)

相关推荐

  • windows 64位下mysql 8.0.13 安装配置方法图文教程

    本文为大家分享了mysql 8.0.13 安装配置教程,供大家参考,具体内容如下 先去官网下载点击的MySQL的下载 下载完成后解压 解压完是这个样子  配置系统环境变量 复制解压后的mysql到C盘或者其他磁盘下 我们去系统的环境变量的path里添加一个mysql的配置  指向mysql的bin目录 配置初始化的my.ini文件的文件 解压后的目录并没有的my.ini文件,没关系可以自行创建在安装根目录下添加的my.ini(新建文本文件,将文件类型改为的.ini),写入基本配置: [mysql

  • mysql 8.0.12 winx64详细安装教程

    本文为大家分享了mysql 8.0.12的 安装教程,供大家参考,具体内容如下 安装教程环境: 系统:Windows8.1 安装包:mysql-8.0.12-winx64 .zip 1.到MySQL官网下载安装包:https://dev.mysql.com/downloads/mysql/: 选择合适的版本: 2.将下载好的安装包(mysql-8.0.12-winx64 .zip)解压到相应路径下: (我的安装路径是:E:\SQLServer\MySQL) 3.在安装目录下新建一个配置文件,命名

  • Windows下MySQL8.0.11社区绿色版安装步骤图解

    在本教程中使用MySQL最新的MySQL服务8.0.11的社区绿色版本进行安装,绿色版为zip格式的包,安装分为以下四步走: 第一步: 下载MySQL社区绿色版服务包 第二步: 新建并配置MySQL的初始化" my.ini "文件 第三步: 使用安装命令进行安装,安装完成后进行初始化 第四步: 启动MySQL服务 第五步: 登陆,修改密码后再登录 第一步: mysql-8.0.11-winx64位绿色版CSDN下载 https://download.csdn.net/download/

  • mysql 8.0.12 解压版安装教程

    本文为大家分享了mysql 8.0.12 解压版安装教程,供大家参考,具体内容如下 1.首先在官网上下载mysql8.0.12的压缩包:下载地址 2.下载成功后解压到任意目录,比如我的是E:\download\mysql-8.0.12-winx64: 3.配置环境变量,在系统变量path的末尾追加解压后的bin文件夹所在目录:E:\download\mysql-8.0.12-winx64\mysql-8.0.12-winx64; 4.以管理员身份运行cmd,如果不是管理员则不能注册mysql服务

  • mysql 8.0.12 安装配置方法并修改密码

    本文记录了mysql 8.0.12 安装配置方法,供大家参考,具体内容如下 1.从官网下载MySQL for Windows:https://dev.mysql.com/downloads/mysql/ 2.安装在本机"D:mysql":解压zip文件后将解压得到的文件夹内的全部文件拷贝到D盘的mysql文件夹下即可. 3.创建mysql.ini文件,放在D:mysql文件下即可,文件内容为: [mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 b

  • windows10系统安装mysql-8.0.13(zip安装) 的教程详解

    安装环境说明 •系统版本:windows10 •mysql版本:mysql-8.0.13-winx64.zip •下载地址:http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-8.0.13-winx64.zip 解压安装包 •解压路径:D:\develop\software •解压后mysql根目录:D:\develop\software\mysql-8.0.13-winx64 原则: 安装目录不能有空格.不能有中文 配置文件 •my.i

  • mysql 8.0.12 安装配置方法图文教程

    记录了mysql 8.0.12 的安装配置方法,分享给大家. 一.安装 1.从网上下载MySQL8.0.12版本,下载地址 2. 下载完成后解压 我解压的路径是:D:\Java\mysql-8.0.12-winx64 3. 配置文件 首先在解压的路径下查看是否含有my.ini的文件,如果没有则新建一个,内容如下: [mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 basedir=D:\Java\mysql-8.0.12-winx64 # 设置mysql数据

  • MySQL Community Server 8.0.11安装配置方法图文教程

    最近开始学习数据库知识,从mysql下手,下面详细介绍一下安装过程,给小伙伴们一个参考. 一.安装 首先,从mysql的中文社区下载,我尝试过其他下载方式,发现还是中文社区下载的安装包最好,下载地址是, 下载完成后,运行安装文件,运行后,出现如下界面: 等待几十秒左右,就会出现安装界面啦. 和安装其他软件一样需要勾选"I accept the license terms",然后点击"next": 这里选择"custom",也可以根据自己需求选择要

  • mysql installer community 8.0.12.0安装图文教程

    本文教程为大家分享了mysql installer community 8.0.12.0的安装,供大家参考 一.下载mysql-installer-community-8.0.12.0.msi 点击 :下载链接 二.安装mysql-installer-community-8.0.12.0.msi 1.点击安装包进入安装页面,选中I accept the license terms 2.一直点击next,遇到此页面,点击yes,然后点击execute,等待安装. 3.安装成功以后,一直点击next

  • mysql8.0.11 winx64安装配置方法图文教程(win10)

    mysql 8.0.11 winx64安装教程记录如下,分享给大家 1.进入地址: 下载mysql-8.0.11-winx64 2.解压zip包,并将解压文件放入一个文件夹下,如图: 3.配置环境变量(目的是为了避免在CMD窗口下操作时反复切换路径) 在Path下添加 D:\Program Files\mysql-8.0.11-winx64\bin 4.编写配置文件 我们发现解压后的目录并没有my.ini(或my-default.ini)文件,没关系可以自行创建.在安装根目录下添加 my.ini

随机推荐