第一步:获取mysql YUM源

进入mysql官网获取RPM包下载地址
https://dev.mysql.com/downloads/repo/yum/

 
image.png

点击下载

 
image.png

获取到下载链接:
https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm


第二步:下载和安装mysql源

  • 进入mysql文件夹,没有的自行创建
  1. [root@VM_0_10_centos /]# cd /usr/local/mysql/
  2. [root@VM_0_10_centos mysql]#
  • 下载源安装包
  1. [root@VM_0_10_centos mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
  2. --2018-08-04 10:29:39-- https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
  3. Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
  4. Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
  5. HTTP request sent, awaiting response... 200 OK
  6. Length: 25820 (25K) [application/x-redhat-package-manager]
  7. Saving to: mysql80-community-release-el7-1.noarch.rpm
  8. 100%[==========================================================================>] 25,820 112KB/s in 0.2s
  9. 2018-08-04 10:29:40 (112 KB/s) - mysql80-community-release-el7-1.noarch.rpm saved [25820/25820]
  10. [root@VM_0_10_centos mysql]# ll
  11. total 28
  12. -rw-r--r-- 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
  13. [root@VM_0_10_centos mysql]#
  • 安装mysql源
  1. [root@VM_0_10_centos mysql]# yum -y localinstall mysql80-community-release-el7-1.noarch.rpm

第三步:在线安装MySQL

  1. [root@VM_0_10_centos mysql]# yum -y install mysql-community-server

下载东西比较多,等几分钟。

第四步:启动Mysql服务

  1. [root@VM_0_10_centos mysql]# systemctl start mysqld

第五步:设置开机启动

  1. [root@VM_0_10_centos mysql]# systemctl enable mysqld
  2. [root@VM_0_10_centos mysql]# systemctl daemon-reload

第六步:修改root本地登录密码

mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。用grep命令搜一下

  1. [root@VM_0_10_centos mysql]# grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
  2. 2018-08-02T02:19:55.829527Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !J:KUwU9y0ZR
  3. 2018-08-02T04:49:34.979689Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pw</s9,Wivm2
  4. 2018-08-04T02:40:46.781768Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nNyK,Y)Wd0-G
  5. [root@VM_0_10_centos mysql]#

这里有三条搜索结果,因为我重复装了3次MySQL,如果第一次安装是只会有一条的。
直接拿到临时默认密码 : nNyK,Y)Wd0-G

  • 登录MySQL
  1. [root@VM_0_10_centos mysql]# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 8
  5. Server version: 8.0.12
  6. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql>
  • 更改root账户临时密码
  1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pwd123@easyoh.net';
  2. Query OK, 0 rows affected (0.03 sec)
  3. mysql>

Pwd123@easyoh.net 请替换成你自己的密码。
(备注 mysql8.0默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位)

第七步:创建新用户、授权、远程登录(不要直接使用root账户登录)

  • 创建easyoh-mp用户并且授权远程登录
  1. mysql> CREATE USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net';
  2. Query OK, 0 rows affected (0.04 sec)
  3. mysql> GRANT ALL ON *.* TO 'easyoh-mp'@'%';
  4. Query OK, 0 rows affected (0.03 sec)
  5. mysql>
  • 在sqlyog客户端用easyoh-mp账户登录(其他客户端也可以,随意)
 
image.png

发现会报plugin caching_sha2_password错误。这是因为MySQL8.0密码策略默认为caching_sha2_password。与5.7有所不同。

  • 进入MySQL数据库查询user表信息
  1. mysql> use mysql;
  2. Database changed
  3. mysql> select user,host,plugin from user;
  4. +------------------+-----------+-----------------------+
  5. | user | host | plugin |
  6. +------------------+-----------+-----------------------+
  7. | easyoh-mp | % | caching_sha2_password |
  8. | mysql.infoschema | localhost | caching_sha2_password |
  9. | mysql.session | localhost | caching_sha2_password |
  10. | mysql.sys | localhost | caching_sha2_password |
  11. | root | localhost | caching_sha2_password |
  12. +------------------+-----------+-----------------------+
  13. 5 rows in set (0.00 sec)
  14. mysql>

发现确实是caching_sha2_password

  • 依次执行下面语句
  1. mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net' PASSWORD EXPIRE NEVER;
  2. Query OK, 0 rows affected (0.04 sec)
  3. mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED WITH mysql_native_password BY 'Pwd123@easyoh.net';
  4. Query OK, 0 rows affected (0.05 sec)
  5. mysql> FLUSH PRIVILEGES;
  6. Query OK, 0 rows affected (0.01 sec)
  7. mysql>

再次登录就可以登录成功了。

第8步:编码

  1. mysql> show variables like '%character%';
  2. +--------------------------+--------------------------------+
  3. | Variable_name | Value |
  4. +--------------------------+--------------------------------+
  5. | character_set_client | utf8mb4 |
  6. | character_set_connection | utf8mb4 |
  7. | character_set_database | utf8mb4 |
  8. | character_set_filesystem | binary |
  9. | character_set_results | utf8mb4 |
  10. | character_set_server | utf8mb4 |
  11. | character_set_system | utf8 |
  12. | character_sets_dir | /usr/share/mysql-8.0/charsets/ |
  13. +--------------------------+--------------------------------+
  14. 8 rows in set (0.01 sec)
  15. mysql>

MySQL8.0默认就是utf8mb4编码,无需更改。
OK 至此 Mysql安装配置完毕;

全流程操作记录

  1. [root@VM_0_10_centos ~]#
  2. [root@VM_0_10_centos /]# cd /usr/local/mysql/
  3. [root@VM_0_10_centos mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
  4. --2018-08-04 10:29:39-- https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
  5. Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
  6. Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
  7. HTTP request sent, awaiting response... 200 OK
  8. Length: 25820 (25K) [application/x-redhat-package-manager]
  9. Saving to: mysql80-community-release-el7-1.noarch.rpm
  10. 100%[==========================================================================>] 25,820 112KB/s in 0.2s
  11. 2018-08-04 10:29:40 (112 KB/s) - mysql80-community-release-el7-1.noarch.rpm saved [25820/25820]
  12. [root@VM_0_10_centos mysql]# ll
  13. total 28
  14. -rw-r--r-- 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
  15. [root@VM_0_10_centos mysql]# yum -y localinstall mysql80-community-release-el7-1.noarch.rpm
  16. Loaded plugins: fastestmirror, langpacks
  17. Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
  18. Marking mysql80-community-release-el7-1.noarch.rpm to be installed
  19. Resolving Dependencies
  20. --> Running transaction check
  21. ---> Package mysql80-community-release.noarch 0:el7-1 will be installed
  22. --> Finished Dependency Resolution
  23. Dependencies Resolved
  24. =================================================================================================================================================================================================================
  25. Package Arch Version Repository Size
  26. =================================================================================================================================================================================================================
  27. Installing:
  28. mysql80-community-release noarch el7-1 /mysql80-community-release-el7-1.noarch 31 k
  29. Transaction Summary
  30. =================================================================================================================================================================================================================
  31. Install 1 Package
  32. Total size: 31 k
  33. Installed size: 31 k
  34. Downloading packages:
  35. Running transaction check
  36. Running transaction test
  37. Transaction test succeeded
  38. Running transaction
  39. Warning: RPMDB altered outside of yum.
  40. Installing : mysql80-community-release-el7-1.noarch 1/1
  41. Verifying : mysql80-community-release-el7-1.noarch 1/1
  42. Installed:
  43. mysql80-community-release.noarch 0:el7-1
  44. Complete!
  45. [root@VM_0_10_centos mysql]# yum -y install mysql-community-server
  46. Loaded plugins: fastestmirror, langpacks
  47. Loading mirror speeds from cached hostfile
  48. epel 12641/12641
  49. Resolving Dependencies
  50. --> Running transaction check
  51. ---> Package mysql-community-server.x86_64 0:8.0.12-1.el7 will be installed
  52. --> Processing Dependency: mysql-community-common(x86-64) = 8.0.12-1.el7 for package: mysql-community-server-8.0.12-1.el7.x86_64
  53. --> Processing Dependency: mysql-community-client(x86-64) >= 8.0.0 for package: mysql-community-server-8.0.12-1.el7.x86_64
  54. --> Running transaction check
  55. ---> Package mysql-community-client.x86_64 0:8.0.12-1.el7 will be installed
  56. --> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.0 for package: mysql-community-client-8.0.12-1.el7.x86_64
  57. ---> Package mysql-community-common.x86_64 0:8.0.12-1.el7 will be installed
  58. --> Running transaction check
  59. ---> Package mysql-community-libs.x86_64 0:8.0.12-1.el7 will be installed
  60. --> Finished Dependency Resolution
  61. Dependencies Resolved
  62. =================================================================================================================================================================================================================
  63. Package Arch Version Repository Size
  64. =================================================================================================================================================================================================================
  65. Installing:
  66. mysql-community-server x86_64 8.0.12-1.el7 mysql80-community 349 M
  67. Installing for dependencies:
  68. mysql-community-client x86_64 8.0.12-1.el7 mysql80-community 26 M
  69. mysql-community-common x86_64 8.0.12-1.el7 mysql80-community 541 k
  70. mysql-community-libs x86_64 8.0.12-1.el7 mysql80-community 2.2 M
  71. Transaction Summary
  72. =================================================================================================================================================================================================================
  73. Install 1 Package (+3 Dependent packages)
  74. Total download size: 377 M
  75. Installed size: 1.7 G
  76. Downloading packages:
  77. (1/4): mysql-community-common-8.0.12-1.el7.x86_64.rpm | 541 kB 00:00:05
  78. (2/4): mysql-community-client-8.0.12-1.el7.x86_64.rpm | 26 MB 00:00:12
  79. (3/4): mysql-community-server-8.0.12-1.el7.x86_64.rpm | 349 MB 00:02:26
  80. (4/4): mysql-community-libs-8.0.12-1.el7.x86_64.rpm | 2.2 MB 00:03:37
  81. -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  82. Total 1.7 MB/s | 377 MB 00:03:43
  83. Running transaction check
  84. Running transaction test
  85. Transaction test succeeded
  86. Running transaction
  87. Installing : mysql-community-common-8.0.12-1.el7.x86_64 1/4
  88. Installing : mysql-community-libs-8.0.12-1.el7.x86_64 2/4
  89. Installing : mysql-community-client-8.0.12-1.el7.x86_64 3/4
  90. Installing : mysql-community-server-8.0.12-1.el7.x86_64 4/4
  91. Verifying : mysql-community-common-8.0.12-1.el7.x86_64 1/4
  92. Verifying : mysql-community-libs-8.0.12-1.el7.x86_64 2/4
  93. Verifying : mysql-community-client-8.0.12-1.el7.x86_64 3/4
  94. Verifying : mysql-community-server-8.0.12-1.el7.x86_64 4/4
  95. Installed:
  96. mysql-community-server.x86_64 0:8.0.12-1.el7
  97. Dependency Installed:
  98. mysql-community-client.x86_64 0:8.0.12-1.el7 mysql-community-common.x86_64 0:8.0.12-1.el7 mysql-community-libs.x86_64 0:8.0.12-1.el7
  99. Complete!
  100. [root@VM_0_10_centos mysql]# systemctl start mysqld
  101. [root@VM_0_10_centos mysql]# systemctl enable mysqld
  102. [root@VM_0_10_centos mysql]# systemctl daemon-reload
  103. [root@VM_0_10_centos mysql]# grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
  104. 2018-08-02T02:19:55.829527Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !J:KUwU9y0ZR
  105. 2018-08-02T04:49:34.979689Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pw</s9,Wivm2
  106. 2018-08-04T02:40:46.781768Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nNyK,Y)Wd0-G
  107. [root@VM_0_10_centos mysql]# mysql -uroot -p
  108. Enter password:
  109. Welcome to the MySQL monitor. Commands end with ; or \g.
  110. Your MySQL connection id is 8
  111. Server version: 8.0.12
  112. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  113. Oracle is a registered trademark of Oracle Corporation and/or its
  114. affiliates. Other names may be trademarks of their respective
  115. owners.
  116. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  117. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pwd123@easyoh.net';
  118. Query OK, 0 rows affected (0.03 sec)
  119. mysql> CREATE USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net';
  120. Query OK, 0 rows affected (0.04 sec)
  121. mysql> GRANT ALL ON *.* TO 'easyoh-mp'@'%';
  122. Query OK, 0 rows affected (0.03 sec)
  123. mysql> use mysql;
  124. Database changed
  125. mysql> select user,host,plugin from user;
  126. +------------------+-----------+-----------------------+
  127. | user | host | plugin |
  128. +------------------+-----------+-----------------------+
  129. | easyoh-mp | % | caching_sha2_password |
  130. | mysql.infoschema | localhost | caching_sha2_password |
  131. | mysql.session | localhost | caching_sha2_password |
  132. | mysql.sys | localhost | caching_sha2_password |
  133. | root | localhost | caching_sha2_password |
  134. +------------------+-----------+-----------------------+
  135. 5 rows in set (0.00 sec)
  136. mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net' PASSWORD EXPIRE NEVER;
  137. Query OK, 0 rows affected (0.04 sec)
  138. mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED WITH mysql_native_password BY 'Pwd123@easyoh.net';
  139. Query OK, 0 rows affected (0.05 sec)
  140. mysql> FLUSH PRIVILEGES;
  141. Query OK, 0 rows affected (0.01 sec)
  142. mysql> show variables like '%character%';
  143. +--------------------------+--------------------------------+
  144. | Variable_name | Value |
  145. +--------------------------+--------------------------------+
  146. | character_set_client | utf8mb4 |
  147. | character_set_connection | utf8mb4 |
  148. | character_set_database | utf8mb4 |
  149. | character_set_filesystem | binary |
  150. | character_set_results | utf8mb4 |
  151. | character_set_server | utf8mb4 |
  152. | character_set_system | utf8 |
  153. | character_sets_dir | /usr/share/mysql-8.0/charsets/ |
  154. +--------------------------+--------------------------------+
  155. 8 rows in set (0.01 sec)

这里有个问题,新密码设置的时候如果设置的过于简单会报错:

原因是因为MySQL有密码设置的规范,具体是与validate_password_policy的值有关:

MySQL完整的初始密码规则可以通过如下命令查看:

  1. mysql> SHOW VARIABLES LIKE 'validate_password%';
  2. +--------------------------------------+-------+
  3. | Variable_name | Value |
  4. +--------------------------------------+-------+
  5. | validate_password_check_user_name | OFF |
  6. | validate_password_dictionary_file | |
  7. | validate_password_length | 4 |
  8. | validate_password_mixed_case_count | 1 |
  9. | validate_password_number_count | 1 |
  10. | validate_password_policy | LOW |
  11. | validate_password_special_char_count | 1 |
  12. +--------------------------------------+-------+
  13. 7 rows in set (0.01 sec)

密码的长度是由validate_password_length决定的,而validate_password_length的计算公式是:

  1. validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)

我的是已经修改过的,初始情况下第一个的值是ON,validate_password_length是8。可以通过如下命令修改:

  1. mysql> set global validate_password_policy=0;
  2. mysql> set global validate_password_length=1;

CentOS 7.4 64位安装配置MySQL8.0的更多相关文章

  1. 阿里云服务器CentOS 5.7(64位)安装配置LAMP服务器(Apache+PHP5+MySQL)

    一.快速安装Apache+PHP5+MySql ----------------------------------------------------- 补充:由于163的yum源上只有php5.1 ...

  2. CentOS 6.5 64位 安装zabbix-2.2.0

    安装环境: VM 10 + CentOS-6.5-x86_64-minimal 虚拟机网络是NAT方式, 动态IP Xshell登录到Centos操作 刚装的centos,啥都没有,先配一下yum 首 ...

  3. 64位 windows10,安装配置MYSQL8.0.13

    MySQL的安装配置过程,一查网上一大堆,但是每个人在安装配置的过程中都会碰到一些问题,因为安装的版本不一样,有些命令可能就不适用了.所以安装之前一定先确认好你的版本号. 下面开始安装MYSQL8.0 ...

  4. Centos6.7 64位安装配置kvm虚拟化

    首先,需要我们的cpu支持虚拟化,有的机器支持但是并未在bios开启,这个需要事先开启. 1. Dell R710安装centos6.7 64位 ,Dell R710在开机后按F2进入BIOS,Pro ...

  5. Windows7 64位安装配置Apache2.4+PHP5.4+MySQL5.5+Xdebug

    PHP更新已经到了5.4.7了,之前是用PHPstudy安装的PHP5.2.13版本,今天有空,就把之前的集成安装卸载了.换上了新一代PHP,记录一下.. 环境:Windows7 64位(内部版本76 ...

  6. CentOS 6.5 64位 安装Nginx, MySQL, PHP

    此篇文章参考了一些网站找的教程,自己遇到了很多坑,写一下自己的安装全过程. 服务器是腾讯云的.安装了centos 6.5系统. 一. 安装Nginx 1.首先安装GCC,make,C++编译器 yum ...

  7. odoo8.0 win7 64位 安装配置(补遗)

    各种参考博客资源--http://www.cnblogs.com/yiguxianyun/p/6256641.html 最开始蛋疼问题的是安装各种site-packages! 云盘里面有些win764 ...

  8. 64位 windows10,MYSQL8.0.13重置密码(忘记密码或者无法登录)

    上一节的MySQL的配置安装里,并没有用到配置文件my.ini.那在MYSQL8.0.13如何解决密码重置问题呢.我去网上搜了好多的资料都是改配置文件my.ini的,后来终于找到了一条命令:操作步骤如 ...

  9. win10下安装配置mysql-8.0.13

    1.下载mysql-8.0.13安装包 https://dev.mysql.com/downloads/mysql/ 选择zip安装包下载就好. 2.解压到你要安装的目录 3.创建my.ini配置文件 ...

随机推荐

  1. Python之配置日志的几种方式(logging模块)

    原文:https://blog.csdn.net/WZ18810463869/article/details/81147167 作为开发者,我们可以通过以下3种方式来配置logging: 1)使用Py ...

  2. unigui+fastreport报表打印

    unigui+fastreport报表打印   unigui+fastreport报表打印 FASTREPORT导出成PDF报表,UNIGUI的TUniURLFrame显示PDF报表并打印. func ...

  3. Web browser的发展演变

    我们每天都在使用着浏览器,每个人使用的浏览器各不一样.在这个科技飞速发展的时代,一个游览器能否站住脚跟取决于使用者的数量,看用户是否喜欢这个产品,听取用户们的意见来改善. 我们这个年龄的人最初用到的浏 ...

  4. apache与tomcat负载集群集成方法配置

    apache与tomcat负载集群集成方法有3种jk.jk_proxy.http_proxy apache:httpd-2.2.17-win32-x86-no_ssl.msi tomcat:apach ...

  5. 配置IDM不限速下载百度云的大文件

    IDM介绍Internet Download Manager(简称IDM)是一个用于Windows系统的下载管理器,它是共享软件,免费试用期为30天,但是每月均有一段时间优惠. IDM可以让用户自动下 ...

  6. HTTP 协议常见的状态码

    HTTP状态码负责表示客户端HTTP请求的返回结果.标记服务器端的处理是否正常.通知出现的错误等工作. 状态码的类别: 记录在RFC2616上的HTTP状态码有40种,再加上WebDAV等的扩展,数量 ...

  7. 简单读!spring-mvc源码之穿越http请求

    相信spring-mvc这种被玩坏了的架构理念,大家都烂熟于胸了,不过还是想来扒一扒他的细节. 一个http请求,怎么样被 spring 接收,又怎样做出响应呢? 一般地,我们会配置一个 web.xm ...

  8. Python 字符串增删改查的使用

    #coding=utf-8a = 'haha'a = "hao"print(a)s = 'Hello World!'print(s.swapcase()) #大写变小写,小写变大写 ...

  9. 超详细的 Redis Cluster 官方集群搭建指南

    今天从 0 开始搭建 Redis Cluster 官方集群,解决搭建过程中遇到的问题,超详细. 安装ruby环境 因为官方提供的创建集群的工具是用ruby写的,需要ruby2.2.2+版本支持,rub ...

  10. DFA算法实现关键字查找(正则原理入门)

    前言:一直都这样认为“正则表达式是一个很有用的技能”,从一开始的磕磕绊绊的使用和摸索,到后来可以得心应手,这个过程离不来平时的不断学习和思考