MySql 8.0.11 installation and configuration tutorial

MySql 8.0.11 installation and configuration tutorial

Official website address: https://dev.mysql.com/downloads/mysql/

I have a RHEL6.5 system here, so I choose RedHat 6 x86, 64bit operating system---download the first RPM Bundle--mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar.

Currently, MySQL 8.0.11 Community Edition provides a variety of installation methods, but no installation instructions for mysql_secure_installation included in the Linux Generic installation package were found.

Therefore, the recommended RPM installation is used here:

1. After decompressing mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar, there are 7 files as follows:

-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

Then create the mysql user:

useradd mysql
passwd mysql

2. The installation order is: (It is recommended to uninstall all previous MySQL related packages before installation, rpm -e --nodeps <package name> is enough)

[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
--I'm too lazy to install perl, so I won't install the test suite.

3. After the installation is complete, the relevant information is as follows:

[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 --Configuration file location-rw-r--r-- 1 root root 1188 Apr 8 16:21 /etc/my.cnf

The default datadir is in /var/lib/mysql/, which can be modified by modifying my.cnf. The startup command is as follows:

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

4. I found that I couldn't log in without a password, so I added skip-grant-tables to my.cnf and restarted to reset the password

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

It can't be changed. . . then:

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

Still can't change, check the password complexity 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 |
+----------------------------------------------+-----------------+

See the official website https://dev.mysql.com/doc/refman/8.0/en/validate-password-options-variables.html#sysvar_validate_password.policy

It is found that there are 3 such values, as shown below:

So set it to 0, and then set validate_password.length to 4, indicating that at least 4 characters are required. The reason why it is set to 4 is because the value of this parameter cannot be less than the result of the following formula:

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

So continue to create users. MySQL 8.0 cancels the syntax of directly granting users. You can only create user first and then grant. Therefore, create root as follows:

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'

Damn...what the hell?

So I went around stackoverflow and everyone said it was a BUG, ​​so I did the following:

mysql> drop user root@'localhost'; --Yes, that's right, although there is no root@'localhost' user, you still have to delete it.
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)

Finally changed the password...Remove the skip-grant-tables parameter in the parameter file and restart the service with service mysqld restart.

5. Finally, the password is set. Create a test user leo and try to connect remotely:

$ 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

My 5.7 mysql tool can't connect, which is embarrassing. Check the authentication related parameters:

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

Check the official website and find that the value of this value is as follows:

The official website also says that this value affects the default encryption algorithm of the password when create user does not explicitly specify the auth plugin. Damn... Doesn't that mean that the leo user I created before uses the default caching_sha2_password authentication? Check it out:

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 |
+------------------+------------+-----------------------+

It's over. It's all fucking over...

Obviously you can't just update the plugin, because that might cause the encrypted password to not be decrypted correctly, and all your passwords will change, so delete all except root@'localhost' and rebuild.

First, you need to add default_authentication_plugin=mysql_native_password in my.cnf, and then restart the service with 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>

So far the remote connection is normal.

Summarize

The above is the MySql 8.0.11 installation and configuration tutorial introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • MySQL 8.0.11 installation summary tutorial diagram
  • Detailed installation tutorial of mysql-8.0.11-winx64.zip
  • mysql8.0.11 winx64 installation and configuration method graphic tutorial (win10)
  • MySQL Community Server 8.0.11 installation and configuration method graphic tutorial
  • MySQL 8.0.11 Community Green Edition Installation Steps Diagram for Windows
  • MySQL 8.0.11 compressed version installation and configuration method graphic tutorial
  • MySQL 8.0.11 MacOS 10.13 installation and configuration method graphic tutorial
  • Detailed tutorial for installing MySQL 8.0.11 compressed version under win10
  • MySQL 8.0.11 MSI version installation and configuration graphic tutorial
  • MySQL 8.0.11 Installation Guide for Mac

<<:  NodeJs high memory usage troubleshooting actual combat record

>>:  Detailed explanation of how to dynamically enable/disable hyperthreading technology in Linux

Recommend

Linux sftp command usage

Concept of SFTP sftp is the abbreviation of Secur...

How to implement element floating and clear floating with CSS

Basic Introduction to Floating In the standard do...

MySQL database migration quickly exports and imports large amounts of data

Database migration is a problem we often encounte...

jQuery simulates picker to achieve sliding selection effect

This article shares the specific code of jQuery t...

...

How to find the my.ini configuration file in MySQL 5.6 under Windows

Make a note so you can come back and check it lat...

Detailed explanation of Vue routing router

Table of contents Using routing plugins in a modu...

A brief discussion on the $notify points of element

My original intention was to encapsulate the $not...

Notes on the MySQL database backup process

Today I looked at some things related to data bac...

Detailed explanation of Docker Secret management and use

1. What is Docker Secret 1. Scenario display We k...