Article directory
- 6. Introduction to business data
-
- 6.4 MySQL installation
-
- 6.4.1 Installation package preparation
- 6.4.2 Install MySQL
- 6.4.3 Configuring MySQL
-
- 6.4.3.1 Enter MySQL with the password you just found (if an error is reported, add single quotation marks to the password)
- 6.4.3.2 Set a complex password (due to the MySQL password policy, this password must be complex enough)
- 6.4.3.3 Change the MySQL password policy
- 6.4.3.4 Set a simple and easy-to-remember password
- 6.4.3.5 Enter MySQL library
- 6.4.3.6 Query user table
- 6.4.3.7 Modify the user table and change the content of the Host table to %
- 6.4.3.8 Refresh
- 6.4.3.9 Exit
6. Introduction to business data
6.4 MySQL installation
6.4.1 Installation package preparation
6.4.1.1 Upload the installation package and JDBC driver to /opt/software, a total of 6
01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
mysql-connector-java-5.1.27-bin.jar
Pull these 6 files into it
6.4.1.2 If it is a virtual machine, follow the steps below
6.4.1.2.1 Uninstall the built-in Mysql-libs (if you have installed MySQL before, you must uninstall them all)
[summer@hadoop102 software]$ rpm -qa | grep -i -E mysql\|mariadb
This statement can check whether you have mysql related components
[summer@hadoop102 software]$ rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps
This statement is to delete all components related to mysql
6.4.2 Install MySQL
6.4.2.1 Install MySQL dependencies
[summer@hadoop102 software]$ sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
[summer@hadoop102 software]$ sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
[summer@hadoop102 software]$ sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
6.4.2.2 Install mysql-client
[summer@hadoop102 software]$ sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
6.4.2.3 Install mysql-server
[summer@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
Note: If the following error is reported, it is caused by the installation of the old version of GPG keys by yum. After rpm version 4.1, the signature of the package will be automatically checked when installing or upgrading the package.
Solution
[summer@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm --force --nodeps
6.4.2.4 Start MySQL
[summer@hadoop102 software]$ sudo systemctl start mysqld
6.4.2.5 View MySQL password
[summer@hadoop102 software]$ sudo cat /var/log/mysqld.log | grep password
Generally, MySQL will give you a default password, so you need to use this command to find out what the password is. Then change it to your desired password
6.4.3 Configuring MySQL
As long as the configuration is the root user + password, you can log in to the MySQL database on any host.
6.4.3.1 Enter MySQL with the password you just found (if an error is reported, add single quotation marks to the password)
[summer@hadoop102 software]$ mysql -uroot -p'password'
6.4.3.2 Set a complex password (due to the MySQL password policy, this password must be complex enough)
mysql> set password=password("QWEqwe123!");
6.4.3.3 Change the MySQL password policy
mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0;
6.4.3.4 Set a simple and easy-to-remember password
mysql> set password=password("000000");
6.4.3.5 Enter MySQL library
mysql> use mysql
6.4.3.6 Query user table
mysql> select user, host from user;
6.4.3.7 Modify the user table and change the content of the Host table to %
mysql> update user set host="%" where user="root";
6.4.3.8 Refresh
mysql> flush privileges;
6.4.3.9 Exit
mysql> quit;