Reference: https://www.cnblogs.com/bigbrotherer/p/7241845.html#top
1、 MariaDB is installed by default in CentOS. This is a branch of MySQL, but for needs, MySQL must be installed in the system, and MariaDB can be overwritten directly after the installation is complete.
Download and install the official Yum Repository of MySQL. Of course, although they are all operated according to the instructions, you must ensure that you are successfully connected to the Internet, otherwise you cannot download.
I started executing the command and reported an error: [root@slaver4 ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
1[ root@slaver4 ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2- - 2019- 07- 0922:04:21- - http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
3 Resolving host dev.mysql.com(dev.mysql.com)...137.254.60.114 Connecting to dev.mysql.com(dev.mysql.com)|137.254.60.11|:80...connected.
5 HTTP request has been sent, waiting for response...301 Moved Permanently
6 Location: https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm [Follow to new URL]7--2019-07-0922:04:22-- https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
8 Connecting dev.mysql.com(dev.mysql.com)|137.254.60.11|:443...Failure: Connection refused.
9 Resolving host dev.mysql.com(dev.mysql.com)...137.254.60.1110 is connecting to dev.mysql.com(dev.mysql.com)|137.254.60.11|:443...Failure: Connection refused.
11- c:No such file or directory
12 in-The URL cannot be found in c.
I executed it again, and it doesn't seem to report an error:
1[ root@slaver4 package]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2- - 2019- 07- 0922:06:47- - http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
3 Resolving host dev.mysql.com(dev.mysql.com)...137.254.60.114 Connecting to dev.mysql.com(dev.mysql.com)|137.254.60.11|:80...connected.
5 HTTP request has been sent, waiting for response...301 Moved Permanently
6 Location: https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm [Follow to new URL]7--2019-07-0922:06:51-- https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
8 Connecting dev.mysql.com(dev.mysql.com)|137.254.60.11|:443...connected.
9 HTTP request has been sent, waiting for response...302 Found
10 Location: https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm [Follow to new URL]11--2019-07-0922:06:53-- https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm12 is parsing host repo.mysql.com(repo.mysql.com)...23.53.253.12913 is connecting to repo.mysql.com(repo.mysql.com)|23.53.253.129|:443...connected.
14 HTTP request has been sent, waiting for response...200 OK
15 Length: 25548(25K)[application/x-redhat-package-manager]16 Saving to: “mysql57-community-release-el7-10.noarch.rpm”
1718100 %[=============================================================================>]25,54855.0KB/s time spent 0.5s
19202019- 07- 0922:06:55(55.0 KB/s)-Saved "mysql57-community-release-el7-10.noarch.rpm” [25548/25548])2122-c:No such file or directory
23 in-The URL cannot be found in c.
24 FINISHED --2019-07-0922:06:55--25 Total wall clock time:8.0s
26 Downloaded:1 files, 25K in0.5s(55.0 KB/s)27[root@slaver4 package]#
Use the above command to directly download the Yum Repository for installation, about 25KB, and then you can directly install it with Yum.
1[ root@slaver4 package]# yum -y install mysql57-community-release-el7-10.noarch.rpm
2 Loaded plugin: fastestmirror, langpacks
3 Checking mysql57-community-release-el7-10.noarch.rpm: mysql57-community-release-el7-10.noarch
4 mysql57-community-release-el7-10.noarch.rpm will be installed
5 Resolving dependencies
6- - > Checking transaction
7- - - > Package mysql57-community-release.noarch.0.el7-10 will be installed
8- - > Resolve dependencies complete
910 Dependency resolution
1112=================================================================================================================================================================================================================13 Package architecture version source size
14=================================================================================================================================================================================================================15 Installing:16 mysql57-community-release noarch el7-10/mysql57-community-release-el7-10.noarch 30 k
1718 Business summary
19=================================================================================================================================================================================================================20 Install 1 package
2122 Total: 30 k
23 Installation size: 30 k
24 Downloading packages:25 Running transaction check
26 Running transaction test
27 Transaction test succeeded
28 Running transaction
29 Installing: mysql57-community-release-el7-10.noarch 1/130 Verifying: mysql57-community-release-el7-10.noarch 1/13132 installed:33 mysql57-community-release.noarch 0:el7-103435 Over!
After that, install the MySQL server. This step may take some time, wait for about 15 minutes, this depends on your internet speed, after the installation is completed, the previous mariadb will be overwritten.
1[ root@slaver4 package]# yum -y install mysql-community-server
2 Loaded plugin: fastestmirror, langpacks
3 Loading mirror speeds from cached hostfile
4* base: mirror.jdcloud.com
5* extras: mirrors.aliyun.com
6* updates: mirrors.aliyun.com
7 Resolving dependencies
8- - > Checking transaction
9- - - > Package mysql-community-server.x86_64.0.5.7.26-1.el7 will be installed
10- - > Processing dependency mysql-community-common(x86-64)=5.7.26-1.el7, it is packaged by mysql-community-server-5.7.26-1.el7.x86_64 Need
11- - > Processing dependency mysql-community-client(x86-64)>=5.7.9. It is used by package mysql-community-server-5.7.26-1.el7.x86_64 Need
12- - > Checking transaction
13- - - > Package mysql-community-client.x86_64.0.5.7.26-1.el7 will be installed
14- - > Processing dependency mysql-community-libs(x86-64)>=5.7.9. It is used by package mysql-community-client-5.7.26-1.el7.x86_64 Need
15- - - > Package mysql-community-common.x86_64.0.5.7.26-1.el7 will be installed
16- - > Checking transaction
17- - - > Package mariadb-libs.x86_64.1.5.5.60-1.el7_5 will be replaced
18- - > Processing dependency libmysqlclient.so.18()(64bit), It is package 2:postfix-2.10.1-7.el7.x86_64 Need
19- - > Processing dependency libmysqlclient.so.18(libmysqlclient_18)(64bit), It is package 2:postfix-2.10.1-7.el7.x86_64 Need
20- - - > Package mysql-community-libs.x86_64.0.5.7.26-1.el7 will be discarded
21- - > Checking transaction
22- - - > Package mysql-community-libs-compat.x86_64.0.5.7.26-1.el7 will be discarded
23- - > Resolve dependencies complete
2425 Dependency resolution
2627=================================================================================================================================================================================================================28 Package architecture version source size
29=================================================================================================================================================================================================================30 Installing:31 mysql-community-libs x86_64 5.7.26-1.el7 mysql57-community 2.2 M
32 Replace mariadb-libs.x86_64 1:5.5.60-1.el7_5
33 mysql-community-libs-compat x86_64 5.7.26-1.el7 mysql57-community 2.0 M
34 Replace mariadb-libs.x86_64 1:5.5.60-1.el7_5
35 mysql-community-server x86_64 5.7.26-1.el7 mysql57-community 166 M
36 Install for dependencies:37 mysql-community-client x86_64 5.7.26-1.el7 mysql57-community 24 M
38 mysql-community-common x86_64 5.7.26-1.el7 mysql57-community 274 k
3940 Business summary
41=================================================================================================================================================================================================================42 Install 3 packages(+2 Dependent packages)4344 Total downloads: 194 M
45 Downloading packages:46 Warning:/var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.26-1.el7.x86_64.rpm:Head V3 DSA/SHA1 Signature,Key ID 5072e1f5: NOKEY ]92 kB/s |366 kB 00:35:58 ETA
47 mysql-community-common-5.7.26-1.el7.x86_64.The public key of rpm has not been installed
48(1 /5): mysql-community-common-5.7.26-1.el7.x86_64.rpm |274 kB 00:00:0249(2/5): mysql-community-libs-5.7.26-1.el7.x86_64.rpm |2.2 MB 00:00:1150(3/5): mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm |2.0 MB 00:00:1051(4/5): mysql-community-client-5.7.26-1.el7.x86_64.rpm |24 MB 00:02:3452(5/5): mysql-community-server-5.7.26-1.el7.x86_64.rpm |166 MB 00:12:1953-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------54 total 260 kB/s |194 MB 00:12:4455 from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql retrieve key 56 import GPG key 0x5072E1F5:57 User ID:"MySQL Release Engineering <[email protected]>"58 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
59 Software package: mysql57-community-release-el7-10.noarch(installed)60 from:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
61 Running transaction check
62 Running transaction test
63 Transaction test succeeded
64 Running transaction
65 Installing: mysql-community-common-5.7.26-1.el7.x86_64 1/666 Installing: mysql-community-libs-5.7.26-1.el7.x86_64 2/667 Installing: mysql-community-client-5.7.26-1.el7.x86_64 3/668 Installing: mysql-community-server-5.7.26-1.el7.x86_64 4/669 Installing: mysql-community-libs-compat-5.7.26-1.el7.x86_64 5/670 Deleting:1:mariadb-libs-5.5.60-1.el7_5.x86_64 6/671 Verifying: mysql-community-server-5.7.26-1.el7.x86_64 1/672 Verifying: mysql-community-client-5.7.26-1.el7.x86_64 2/673 Verifying: mysql-community-libs-5.7.26-1.el7.x86_64 3/674 Verifying: mysql-community-libs-compat-5.7.26-1.el7.x86_64 4/675 Verifying: mysql-community-common-5.7.26-1.el7.x86_64 5/676 Verifying:1:mariadb-libs-5.5.60-1.el7_5.x86_64 6/67778 installed:79 mysql-community-libs.x86_64 0:5.7.26-1.el7 mysql-community-libs-compat.x86_64 0:5.7.26-1.el7 mysql-community-server.x86_64 0:5.7.26-1.el7
8081 Installed as a dependency:82 mysql-community-client.x86_64 0:5.7.26-1.el7 mysql-community-common.x86_64 0:5.7.26-1.el7
8384 Substitute:85 mariadb-libs.x86_64 1:5.5.60-1.el7_5
8687 complete!
88[ root@slaver4 package]#
2、 Mysql configuration.
First start Mysql. Then check the running status of MySQL, as shown in the figure:
1[ root@slaver4 package]# systemctl start mysqld.service
2[ root@slaver4 package]# systemctl status mysqld.service
3 ● mysqld.service - MySQL Server
4 Loaded:loaded(/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)5 Active:active(running)since two 2019-07-0922:27:30 CST; 20s ago
6 Docs: man:mysqld(8)7 http://dev.mysql.com/doc/refman/en/using-systemd.html
8 Process:9204 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS(code=exited, status=0/SUCCESS)9 Process:9122 ExecStartPre=/usr/bin/mysqld_pre_systemd(code=exited, status=0/SUCCESS)10 Main PID:9207(mysqld)11 Tasks:2712 CGroup:/system.slice/mysqld.service
13 └─9207/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
14157 Month 0922:27:15 slaver4 systemd[1]: Starting MySQL Server...167Month 0922:27:30 slaver4 systemd[1]: Started MySQL Server.17[root@slaver4 package]#
At this point MySQL has started to run normally, but if you want to enter MySQL, you must first find out the password of the root user at this time. You can find the password in the log file by using the following command:
1[ root@slaver4 package]# grep "password"/var/log/mysqld.log
22019- 07- 09 T14:27:27.564729Z 1[Note] A temporary password is generated for root@localhost: 1j:nj40f35%N
Enter the database with the following command:
Enter the initial password, you can't do anything at this time, because MySQL must change the password to operate the database by default:
1 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';2 ERROR 1819(HY000): Your password does not satisfy the current policy requirements
There is a problem here. If the new password is set too simple, an error will be reported:
For specific reasons, please check the reference link: https://www.cnblogs.com/bigbrotherer/p/7241845.html#top
The complete initial password rules of MySQL can be viewed with the following command:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
After setting, it is the values I found above. At this time, the password can be set very simple, such as 1234. The password setting of this database is complete.
1 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';2 ERROR 1819(HY000): Your password does not satisfy the current policy requirements
3 mysql> SHOW VARIABLES LIKE 'validate_password%';4 ERROR 1820(HY000): You must reset your password using ALTER USER statement before executing this statement.5 mysql>set global validate_password_policy=0;6 Query OK,0 rows affected(0.00 sec)78 mysql>set global validate_password_length=1;9 Query OK,0 rows affected(0.00 sec)1011 mysql> SHOW VARIABLES LIKE 'validate_password%';12 ERROR 1820(HY000): You must reset your password using ALTER USER statement before executing this statement.13 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';14 Query OK,0 rows affected(0.00 sec)1516 mysql> SHOW VARIABLES LIKE 'validate_password%';17+--------------------------------------+-------+18| Variable_name | Value |19+--------------------------------------+-------+20| validate_password_check_user_name | OFF |21| validate_password_dictionary_file ||22| validate_password_length |4|23| validate_password_mixed_case_count |1|24| validate_password_number_count |1|25| validate_password_policy | LOW |26| validate_password_special_char_count |1|27+--------------------------------------+-------+287 rows inset(0.01 sec)2930 mysql>
But there is still a problem at this time, because Yum Repository is installed, and every yum operation will be automatically updated in the future, you need to uninstall this:
1[ root@slaver4 package]# yum -y remove mysql57-community-release-el7-10.noarch
2 Loaded plugin: fastestmirror, langpacks
3 Resolving dependencies
4- - > Checking transaction
5- - - > Package mysql57-community-release.noarch.0.el7-10 will be deleted
6- - > Resolve dependencies complete
78 Dependency resolution
910=================================================================================================================================================================================================================11 Package architecture version source size
12=================================================================================================================================================================================================================13 deleting:14 mysql57-community-release noarch el7-10 installed 30 k
1516 Business summary
17=================================================================================================================================================================================================================18 Remove 1 package
1920 Installation size: 30 k
21 Downloading packages:22 Running transaction check
23 Running transaction test
24 Transaction test succeeded
25 Running transaction
26 deleting: mysql57-community-release-el7-10.noarch 1/127 Verifying: mysql57-community-release-el7-10.noarch 1/12829 delete:30 mysql57-community-release.noarch 0:el7-103132 Over!
33[ root@slaver4 package]#
However, the goose reported an error:
Solve Navicat error: 1130-host. Is not allowed to connect to this MySql server, MySQL.
1[ root@slaver4 package]# mysql -u root -p
2 Enter password:3 Welcome to the MySQL monitor. Commands end with; or \g.4 Your MySQL connection id is 115 Server version:5.7.26 MySQL Community Server(GPL)67Copyright(c)2000,2019, Oracle and/or its affiliates. All rights reserved.89 Oracle is a registered trademark of Oracle Corporation and/or its
10 affiliates. Other names may be trademarks of their respective
11 owners.1213 Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.1415 mysql> use mysql;16 Reading table information for completion of table and column names
17 You can turn off this feature to get a quicker startup with-A
1819 Database changed
20 mysql> update user set host='%' where user='root';21 Query OK,0 rows affected(0.01 sec)22 Rows matched:1 Changed:0 Warnings:02324 mysql> select host,user from user;25+-----------+---------------+26| host | user |27+-----------+---------------+28|%| root |29| localhost | mysql.session |30| localhost | mysql.sys |31+-----------+---------------+323 rows inset(0.00 sec)3334 mysql> flush privileges;35 Query OK,0 rows affected(0.00 sec)3637 mysql>
to be continued......
Recommended Posts