侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

MySql 8.0.11安装配置教程

数据库  /  管理员 发布于 6年前   121

官网地址: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 mysqlpasswd mysql

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

[root@python ~]# rpm -ivh mysql-community-common-8.0.11-1.el6.x86_64.rpmwarning: mysql-community-common-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing...        ########################################### [100%]  1:mysql-community-common ########################################### [100%][root@python ~]# rpm -ivh mysql-community-libs-8.0.11-1.el6.x86_64.rpmwarning: mysql-community-libs-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing...        ########################################### [100%]  1:mysql-community-libs  ########################################### [100%][root@python ~]# rpm -ivh mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpmwarning: mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing...        ########################################### [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.rpmwarning: mysql-community-libs-compat-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing...        ########################################### [100%]  1:mysql-community-libs-co########################################### [100%][root@python ~]# rpm -ivh mysql-community-server-8.0.11-1.el6.x86_64.rpmwarning: mysql-community-server-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYerror: 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.rpmwarning: mysql-community-client-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing...        ########################################### [100%]  1:mysql-community-client ########################################### [100%][root@python ~]# rpm -ivh mysql-community-server-8.0.11-1.el6.x86_64.rpmwarning: mysql-community-server-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing...        ########################################### [100%]  1:mysql-community-server ########################################### [100%][root@python ~]# rpm -ivh mysql-community-devel-8.0.11-1.el6.x86_64.rpmwarning: mysql-community-devel-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing...        ########################################### [100%]  1:mysql-community-devel ########################################### [100%]^[[A[root@python ~]# rpm -ivh mysql-community-test-8.0.11-1.el6.x86_64.rpmwarning: mysql-community-test-8.0.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYerror: Failed dependencies:  perl(JSON) is needed by mysql-community-test-8.0.11-1.el6.x86_64--懒的去装perl了,因此测试套件就不装了。

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

[root@python ~]# mysql -Vmysql 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 startInitializing 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 statementmysql> exitBye

居然不能改。。。于是:

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.193mysql: [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 -Vmysql Ver 14.14 Distrib 5.7.20, for Linux (x86_64) using EditLine wrapper$ mysql -uleo -pmysql -h192.168.1.193mysql: [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 16Server version: 8.0.11 MySQL Community Server - GPLCopyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

至此远程连接正常。

总结

以上所述是小编给大家介绍的MySql 8.0.11安装配置教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对站的支持!


  • 上一条:
    Mac MySQL重置Root密码的教程
    下一条:
    MySQL外键约束常见操作方法示例【查看、添加、修改、删除】
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • 分库分表的目的、优缺点及具体实现方式介绍(0个评论)
    • DevDB - 在 VS 代码中直接访问数据库(0个评论)
    • 在ubuntu系统中实现mysql数据存储目录迁移流程步骤(0个评论)
    • 在mysql中使用存储过程批量新增测试数据流程步骤(0个评论)
    • php+mysql数据库批量根据条件快速更新、连表更新sql实现(0个评论)
    • 近期文章
    • 智能合约Solidity学习CryptoZombie第三课:组建僵尸军队(高级Solidity理论)(0个评论)
    • 智能合约Solidity学习CryptoZombie第二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2017-06
    • 2017-08
    • 2017-09
    • 2017-10
    • 2017-11
    • 2018-01
    • 2018-05
    • 2018-10
    • 2018-11
    • 2020-02
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-08
    • 2020-09
    • 2021-02
    • 2021-04
    • 2021-07
    • 2021-08
    • 2021-11
    • 2021-12
    • 2022-02
    • 2022-03
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-07
    • 2023-08
    • 2023-10
    • 2023-11
    • 2023-12
    • 2024-01
    • 2024-03
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客