CentOS 7.4 64位安装配置MySQL8.0
第一步:获取mysql YUM源
进入mysql官网获取RPM包下载地址
https://dev.mysql.com/downloads/repo/yum/

点击下载

获取到下载链接:
https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
第二步:下载和安装mysql源
- 进入mysql文件夹,没有的自行创建
[root@VM_0_10_centos /]# cd /usr/local/mysql/
[root@VM_0_10_centos mysql]#
- 下载源安装包
[root@VM_0_10_centos mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
--2018-08-04 10:29:39-- https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’
100%[==========================================================================>] 25,820 112KB/s in 0.2s
2018-08-04 10:29:40 (112 KB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820]
[root@VM_0_10_centos mysql]# ll
total 28
-rw-r--r-- 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
[root@VM_0_10_centos mysql]#
- 安装mysql源
[root@VM_0_10_centos mysql]# yum -y localinstall mysql80-community-release-el7-1.noarch.rpm
第三步:在线安装MySQL
[root@VM_0_10_centos mysql]# yum -y install mysql-community-server
下载东西比较多,等几分钟。
第四步:启动Mysql服务
[root@VM_0_10_centos mysql]# systemctl start mysqld
第五步:设置开机启动
[root@VM_0_10_centos mysql]# systemctl enable mysqld
[root@VM_0_10_centos mysql]# systemctl daemon-reload
第六步:修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。用grep命令搜一下
[root@VM_0_10_centos mysql]# grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
2018-08-02T02:19:55.829527Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !J:KUwU9y0ZR
2018-08-02T04:49:34.979689Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pw</s9,Wivm2
2018-08-04T02:40:46.781768Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nNyK,Y)Wd0-G
[root@VM_0_10_centos mysql]#
这里有三条搜索结果,因为我重复装了3次MySQL,如果第一次安装是只会有一条的。
直接拿到临时默认密码 : nNyK,Y)Wd0-G
- 登录MySQL
[root@VM_0_10_centos mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12
Copyright (c) 2000, 2018, 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>
- 更改root账户临时密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pwd123@easyoh.net';
Query OK, 0 rows affected (0.03 sec)
mysql>
Pwd123@easyoh.net 请替换成你自己的密码。
(备注 mysql8.0默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位)
第七步:创建新用户、授权、远程登录(不要直接使用root账户登录)
- 创建
easyoh-mp
用户并且授权远程登录
mysql> CREATE USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net';
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL ON *.* TO 'easyoh-mp'@'%';
Query OK, 0 rows affected (0.03 sec)
mysql>
- 在sqlyog客户端用
easyoh-mp
账户登录(其他客户端也可以,随意)

发现会报plugin caching_sha2_password错误。这是因为MySQL8.0密码策略默认为caching_sha2_password。与5.7有所不同。
- 进入MySQL数据库查询user表信息
mysql> use mysql;
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| easyoh-mp | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)
mysql>
发现确实是caching_sha2_password
- 依次执行下面语句
mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.04 sec)
mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED WITH mysql_native_password BY 'Pwd123@easyoh.net';
Query OK, 0 rows affected (0.05 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql>
再次登录就可以登录成功了。
第8步:编码
mysql> show variables like '%character%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.01 sec)
mysql>
MySQL8.0默认就是utf8mb4编码,无需更改。
OK 至此 Mysql安装配置完毕;
全流程操作记录
[root@VM_0_10_centos ~]#
[root@VM_0_10_centos /]# cd /usr/local/mysql/
[root@VM_0_10_centos mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
--2018-08-04 10:29:39-- https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’
100%[==========================================================================>] 25,820 112KB/s in 0.2s
2018-08-04 10:29:40 (112 KB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820]
[root@VM_0_10_centos mysql]# ll
total 28
-rw-r--r-- 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
[root@VM_0_10_centos mysql]# yum -y localinstall mysql80-community-release-el7-1.noarch.rpm
Loaded plugins: fastestmirror, langpacks
Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
Marking mysql80-community-release-el7-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
mysql80-community-release noarch el7-1 /mysql80-community-release-el7-1.noarch 31 k
Transaction Summary
=================================================================================================================================================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql80-community-release-el7-1.noarch 1/1
Verifying : mysql80-community-release-el7-1.noarch 1/1
Installed:
mysql80-community-release.noarch 0:el7-1
Complete!
[root@VM_0_10_centos mysql]# yum -y install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel 12641/12641
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.12-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.12-1.el7 for package: mysql-community-server-8.0.12-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.0 for package: mysql-community-server-8.0.12-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.12-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.0 for package: mysql-community-client-8.0.12-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.12-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:8.0.12-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
mysql-community-server x86_64 8.0.12-1.el7 mysql80-community 349 M
Installing for dependencies:
mysql-community-client x86_64 8.0.12-1.el7 mysql80-community 26 M
mysql-community-common x86_64 8.0.12-1.el7 mysql80-community 541 k
mysql-community-libs x86_64 8.0.12-1.el7 mysql80-community 2.2 M
Transaction Summary
=================================================================================================================================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 377 M
Installed size: 1.7 G
Downloading packages:
(1/4): mysql-community-common-8.0.12-1.el7.x86_64.rpm | 541 kB 00:00:05
(2/4): mysql-community-client-8.0.12-1.el7.x86_64.rpm | 26 MB 00:00:12
(3/4): mysql-community-server-8.0.12-1.el7.x86_64.rpm | 349 MB 00:02:26
(4/4): mysql-community-libs-8.0.12-1.el7.x86_64.rpm | 2.2 MB 00:03:37
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.7 MB/s | 377 MB 00:03:43
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-8.0.12-1.el7.x86_64 1/4
Installing : mysql-community-libs-8.0.12-1.el7.x86_64 2/4
Installing : mysql-community-client-8.0.12-1.el7.x86_64 3/4
Installing : mysql-community-server-8.0.12-1.el7.x86_64 4/4
Verifying : mysql-community-common-8.0.12-1.el7.x86_64 1/4
Verifying : mysql-community-libs-8.0.12-1.el7.x86_64 2/4
Verifying : mysql-community-client-8.0.12-1.el7.x86_64 3/4
Verifying : mysql-community-server-8.0.12-1.el7.x86_64 4/4
Installed:
mysql-community-server.x86_64 0:8.0.12-1.el7
Dependency Installed:
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
Complete!
[root@VM_0_10_centos mysql]# systemctl start mysqld
[root@VM_0_10_centos mysql]# systemctl enable mysqld
[root@VM_0_10_centos mysql]# systemctl daemon-reload
[root@VM_0_10_centos mysql]# grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
2018-08-02T02:19:55.829527Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !J:KUwU9y0ZR
2018-08-02T04:49:34.979689Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pw</s9,Wivm2
2018-08-04T02:40:46.781768Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nNyK,Y)Wd0-G
[root@VM_0_10_centos mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12
Copyright (c) 2000, 2018, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pwd123@easyoh.net';
Query OK, 0 rows affected (0.03 sec)
mysql> CREATE USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net';
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL ON *.* TO 'easyoh-mp'@'%';
Query OK, 0 rows affected (0.03 sec)
mysql> use mysql;
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| easyoh-mp | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)
mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED BY 'Pwd123@easyoh.net' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.04 sec)
mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED WITH mysql_native_password BY 'Pwd123@easyoh.net';
Query OK, 0 rows affected (0.05 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like '%character%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.01 sec)
这里有个问题,新密码设置的时候如果设置的过于简单会报错:
原因是因为MySQL有密码设置的规范,具体是与validate_password_policy的值有关:
MySQL完整的初始密码规则可以通过如下命令查看:

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 4 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)

密码的长度是由validate_password_length决定的,而validate_password_length的计算公式是:
validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
我的是已经修改过的,初始情况下第一个的值是ON,validate_password_length是8。可以通过如下命令修改:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
CentOS 7.4 64位安装配置MySQL8.0的更多相关文章
- 阿里云服务器CentOS 5.7(64位)安装配置LAMP服务器(Apache+PHP5+MySQL)
一.快速安装Apache+PHP5+MySql ----------------------------------------------------- 补充:由于163的yum源上只有php5.1 ...
- CentOS 6.5 64位 安装zabbix-2.2.0
安装环境: VM 10 + CentOS-6.5-x86_64-minimal 虚拟机网络是NAT方式, 动态IP Xshell登录到Centos操作 刚装的centos,啥都没有,先配一下yum 首 ...
- 64位 windows10,安装配置MYSQL8.0.13
MySQL的安装配置过程,一查网上一大堆,但是每个人在安装配置的过程中都会碰到一些问题,因为安装的版本不一样,有些命令可能就不适用了.所以安装之前一定先确认好你的版本号. 下面开始安装MYSQL8.0 ...
- Centos6.7 64位安装配置kvm虚拟化
首先,需要我们的cpu支持虚拟化,有的机器支持但是并未在bios开启,这个需要事先开启. 1. Dell R710安装centos6.7 64位 ,Dell R710在开机后按F2进入BIOS,Pro ...
- Windows7 64位安装配置Apache2.4+PHP5.4+MySQL5.5+Xdebug
PHP更新已经到了5.4.7了,之前是用PHPstudy安装的PHP5.2.13版本,今天有空,就把之前的集成安装卸载了.换上了新一代PHP,记录一下.. 环境:Windows7 64位(内部版本76 ...
- CentOS 6.5 64位 安装Nginx, MySQL, PHP
此篇文章参考了一些网站找的教程,自己遇到了很多坑,写一下自己的安装全过程. 服务器是腾讯云的.安装了centos 6.5系统. 一. 安装Nginx 1.首先安装GCC,make,C++编译器 yum ...
- odoo8.0 win7 64位 安装配置(补遗)
各种参考博客资源--http://www.cnblogs.com/yiguxianyun/p/6256641.html 最开始蛋疼问题的是安装各种site-packages! 云盘里面有些win764 ...
- 64位 windows10,MYSQL8.0.13重置密码(忘记密码或者无法登录)
上一节的MySQL的配置安装里,并没有用到配置文件my.ini.那在MYSQL8.0.13如何解决密码重置问题呢.我去网上搜了好多的资料都是改配置文件my.ini的,后来终于找到了一条命令:操作步骤如 ...
- win10下安装配置mysql-8.0.13
1.下载mysql-8.0.13安装包 https://dev.mysql.com/downloads/mysql/ 选择zip安装包下载就好. 2.解压到你要安装的目录 3.创建my.ini配置文件 ...
随机推荐
- access纯jdbc连接
Class.forName("com.hxtt.sql.access.AccessDriver"); String url = "jdbc:Access:///c:/a/ ...
- grep 笔记
-a :将 binary 文件以 text 文件的方式搜寻数据-c :计算找到 '搜寻字符串' 的次数-i :忽略大小写的不同,所以大小写视为相同-n :顺便输出行号-v :反向选择,亦即显示出没有 ...
- Mapreduce操作HBase
这个操作和普通的Mapreduce还不太一样,比如普通的Mapreduce输入可以是txt文件等,Mapreduce可以直接读取Hive中的表的数据(能够看见是以类似txt文件形式),但Mapredu ...
- 双十一福利,阿里云1核2G一年最低只要99
活动期间,新用户可任选1款购买,限购1台,拼团后团内每增加1名新购用户,全团再享10%优惠 (50%封顶),买贵返差 又是只给新用户的福利,比上次的699一年的活动要差一点.如果之前注册了没下手的用户 ...
- 1.ActionBar
ActionBar低版本和高版本用法不同 低版本:1. 引用v7-appcompat2. Activity继承ActionBarActivity3. android:theme="@styl ...
- 第39节:Java当中的IO
Java当中的IO IO的分类 第一种分:输入流和输出流 第二种分:字节流和字符流 第三种分:节点流和处理流 节点流处理数据,处理流是节点流基础上加工的. IO中的重点: InputStream Ou ...
- Metasploit Framework(7)客户端渗透(下)
文章的格式也许不是很好看,也没有什么合理的顺序 完全是想到什么写一些什么,但各个方面都涵盖到了 能耐下心看的朋友欢迎一起学习,大牛和杠精们请绕道 应用场景: Kali机器IP:192.168.163. ...
- php过滤 字符
今天在抓取页面中得到字符串:"卡牌 ",使用str_replace . preg_replace 和 strip_tags过滤都无解. 最后google到2种方式,如下: str_ ...
- 过了所有技术面,却倒在 HR 一个问题上。。
面试问离职原因,这是我们广大程序员朋友面试时逃不开的问题,如果答得不好,可能就影响了你整个的面试结果. 最近在栈长的Java技术栈vip群里,我也看到大家在讨论这个问题,其中有个朋友的回复栈长很有感触 ...
- 机器学习(Machine Learning)算法总结-K临近算法
一.算法详解 1.什么是K临近算法 Cover 和 Hart在1968年提出了最初的临近算法 属于分类(classification)算法 邻近算法,或者说K最近邻(kNN,k-NearestNeig ...