按照此流程进行,如有任何问题随时可以微信交流:
微信:shun18301513217
[root@~else~ ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
[root@~else~ ~]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm
[root@~else~ ~]# yum repolist
[root@~else~ ~]# yum list
[root@~else~ ~]# yum install mysql-community-server
...
Is this ok [y/d/N]: y
...
[root@~else~ ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
default-authentication-plugin=mysql_native_password
symbolic-links=0 #
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# no password 先设置免密码登录
skip-grant-tables
[root@~else~ ~]# systemctl start mysqld
[root@~else~ ~]# systemctl status mysqld
[root@~else~ ~]# systemctl enable mysqld
[root@~else~ ~]# systemctl restart mysqld
[root@~else~ ~]# systemctl status mysqld
# 以下不用密码,直接回车
[root@~else~ ~]# mysql -u root -p
Enter password:
[root@~else~ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.17 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set authentication_string='' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> quit
Bye
[root@~else~ ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
default-authentication-plugin=mysql_native_password
symbolic-links=0 #
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# no password 以上将密码设置为了空字符串吗,所以将免密注释掉,免密和密码是空字符串不是同一件事情
# skip-grant-tables
# 重启MySQL的服务,空字符密码串登录,即回车即可
[root@~else~ ~]# systemctl restart mysqld
[root@~else~ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.17
Copyright (c) 2000, 2019, 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> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by '123@QAZwsxedc';
Query OK, 0 rows affected (0.00 sec)
mysql> update user set host='%' where user='root';
ERROR 1046 (3D000): No database selected
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> alter user 'root'@'%' identified with mysql_native_password by '456@WERTSxs';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '456@WERTSxs';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create database reportdb;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| reportdb |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> quit;
Bye
以下是全记录(可以不用看):
[root@~else~ ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
[root@~else~ ~]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm
[root@~else~ ~]# yum repolist
[root@~else~ ~]# yum list
[root@~else~ ~]# yum install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
epel | 5.4 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql80-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.17-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.17-1.el7 for package: mysql-community-server-8.0.17-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.17-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-8.0.17-1.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-8.0.17-1.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-8.0.17-1.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mysql-community-client.x86_64 0:8.0.17-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.17-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.17-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:mariadb-devel-5.5.60-1.el7_5.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.60-1.el7_5 for package: 1:mariadb-devel-5.5.60-1.el7_5.x86_64
---> Package mysql-community-libs.x86_64 0:8.0.17-1.el7 will be obsoleting
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.60-1.el7_5 will be obsoleted
---> Package mysql-community-devel.x86_64 0:8.0.17-1.el7 will be obsoleting
---> Package mysql-community-libs-compat.x86_64 0:8.0.17-1.el7 will be obsoleting
---> Package postfix.x86_64 2:2.10.1-6.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-7.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================
Installing:
mysql-community-devel x86_64 8.0.17-1.el7 mysql80-community 5.5 M
replacing mariadb-devel.x86_64 1:5.5.60-1.el7_5
mysql-community-libs x86_64 8.0.17-1.el7 mysql80-community 3.0 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-libs-compat x86_64 8.0.17-1.el7 mysql80-community 2.1 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-server x86_64 8.0.17-1.el7 mysql80-community 415 M
Installing for dependencies:
libaio x86_64 0.3.109-13.el7 base 24 k
mysql-community-client x86_64 8.0.17-1.el7 mysql80-community 32 M
mysql-community-common x86_64 8.0.17-1.el7 mysql80-community 589 k
Updating for dependencies:
postfix x86_64 2:2.10.1-7.el7 base 2.4 M
Transaction Summary
===========================================================================================================================================================
Install 4 Packages (+3 Dependent packages)
Upgrade ( 1 Dependent package)
Total download size: 461 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/8): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-8.0.17-1.el7.x86_64.rpm is not installed
(2/8): mysql-community-common-8.0.17-1.el7.x86_64.rpm | 589 kB 00:00:00
(3/8): mysql-community-devel-8.0.17-1.el7.x86_64.rpm | 5.5 MB 00:00:00
(4/8): mysql-community-libs-8.0.17-1.el7.x86_64.rpm | 3.0 MB 00:00:01
(5/8): mysql-community-libs-compat-8.0.17-1.el7.x86_64.rpm | 2.1 MB 00:00:00
(6/8): postfix-2.10.1-7.el7.x86_64.rpm | 2.4 MB 00:00:00
(7/8): mysql-community-client-8.0.17-1.el7.x86_64.rpm | 32 MB 00:00:04
(8/8): mysql-community-server-8.0.17-1.el7.x86_64.rpm | 415 MB 00:01:33
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.8 MB/s | 461 MB 00:01:35
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <[email protected]>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql80-community-release-el7-3.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-8.0.17-1.el7.x86_64 1/11
Installing : mysql-community-libs-8.0.17-1.el7.x86_64 2/11
Installing : mysql-community-client-8.0.17-1.el7.x86_64 3/11
Installing : mysql-community-libs-compat-8.0.17-1.el7.x86_64 4/11
Installing : libaio-0.3.109-13.el7.x86_64 5/11
Installing : mysql-community-server-8.0.17-1.el7.x86_64 6/11
Updating : 2:postfix-2.10.1-7.el7.x86_64 7/11
Installing : mysql-community-devel-8.0.17-1.el7.x86_64 8/11
Erasing : 1:mariadb-devel-5.5.60-1.el7_5.x86_64 9/11
Cleanup : 2:postfix-2.10.1-6.el7.x86_64 10/11
Erasing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 11/11
Verifying : mysql-community-libs-8.0.17-1.el7.x86_64 1/11
Verifying : mysql-community-server-8.0.17-1.el7.x86_64 2/11
Verifying : mysql-community-common-8.0.17-1.el7.x86_64 3/11
Verifying : 2:postfix-2.10.1-7.el7.x86_64 4/11
Verifying : mysql-community-devel-8.0.17-1.el7.x86_64 5/11
Verifying : mysql-community-client-8.0.17-1.el7.x86_64 6/11
Verifying : mysql-community-libs-compat-8.0.17-1.el7.x86_64 7/11
Verifying : libaio-0.3.109-13.el7.x86_64 8/11
Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 9/11
Verifying : 2:postfix-2.10.1-6.el7.x86_64 10/11
Verifying : 1:mariadb-devel-5.5.60-1.el7_5.x86_64 11/11
Installed:
mysql-community-devel.x86_64 0:8.0.17-1.el7 mysql-community-libs.x86_64 0:8.0.17-1.el7 mysql-community-libs-compat.x86_64 0:8.0.17-1.el7
mysql-community-server.x86_64 0:8.0.17-1.el7
Dependency Installed:
libaio.x86_64 0:0.3.109-13.el7 mysql-community-client.x86_64 0:8.0.17-1.el7 mysql-community-common.x86_64 0:8.0.17-1.el7
Dependency Updated:
postfix.x86_64 2:2.10.1-7.el7
Replaced:
mariadb-devel.x86_64 1:5.5.60-1.el7_5 mariadb-libs.x86_64 1:5.5.60-1.el7_5
Complete!
[root@~else~ ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
"/etc/my.cnf" 31L, 1243C 1,1 Top
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
~ 1,1 All
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
default-authentication-plugin=mysql_native_password
symbolic-links=0 #
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# no password
skip-grant-tables
~
~
"/etc/my.cnf" 37L, 1348C written
[root@~else~ ~]# systemctl start mysqld
[root@~else~ ~]# systemctl status mysqld
鈼[0m mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-08-08 10:30:02 CST; 11s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 22410 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 22486 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
鈹斺攢22486 /usr/sbin/mysqld
Aug 08 10:29:55 ~else~ systemd[1]: Starting MySQL Server...
Aug 08 10:30:02 ~else~ systemd[1]: Started MySQL Server.
[root@~else~ ~]# systemctl enable mysqld
[root@~else~ ~]# systemctl restart mysqld
[root@~else~ ~]# systemctl status mysqld
鈼[0m mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-08-08 10:32:57 CST; 2s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 22560 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 22584 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
鈹斺攢22584 /usr/sbin/mysqld
Aug 08 10:32:56 ~else~ systemd[1]: Starting MySQL Server...
Aug 08 10:32:57 ~else~ systemd[1]: Started MySQL Server.
[root@~else~ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.17 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set authentication_string='' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> quit
Bye
[root@~else~ ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
default-authentication-plugin=mysql_native_password
symbolic-links=0 #
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# no password
# skip-grant-tables
~
~
"/etc/my.cnf" 37L, 1350C written
[root@~else~ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.17 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> alter user 'root'@'localhost' identified by '123@QAZwsxedc';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> quit
Bye
[root@~else~ ~]# systemctl restart mysqld
[root@~else~ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.17
Copyright (c) 2000, 2019, 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> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by '123@QAZwsxedc';
Query OK, 0 rows affected (0.00 sec)
mysql> update user set host='%' where user='root';
ERROR 1046 (3D000): No database selected
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> alter user 'root'@'%' identified with mysql_native_password by '123@QAZwsxedc';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123@QAZwsxedc';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create database reportdb;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| reportdb |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> quit;
Bye
[root@~else~ ~]#