Use yum to install mysql database in linux-centos 6 environment

(yum installation)
1. Download yum from the mysql official website, http://dev.mysql.com/downloads/repo/yum/. The version is selected according to the needs. I use centos6 so I choose: Red Hat Enterprise Linux 6 / Oracle Linux 6 (Architecture Independent), RPM Package

2. Install the very detailed installation steps on the yum official website: http://dev.mysql. com/doc/refman/5.7/en/linux-installation-yum-repo.html.
(Note:
shell> sudo yum localinstall platform-and-version-specific-package-name.rpm After executing the installation, there are some system version settings to choose from as needed.

shell> sudo yum-config-manager --disable mysql57-community
shell > sudo yum-config-manager --enable mysql56-community
shell> sudo dnf config-manager --disable mysql57-community
shell> sudo dnf config-manager --enable mysql56-community
These four commands are selected according to the currently installed mysql version. At this point, the yum installation is basically ok. Let's start to install the mysql database.)

(database installation)
1. shell> sudo yum install mysql-community-server After executing the command, select "Y" and it will be OK.

2. Start the database: shell> sudo service mysqld start

3. Check the database startup status: shell> sudo service mysqld status

4. Obtain the initial default password of the database: shell> sudo grep 'temporary password' /var/log/mysqld.log

5. Log in with the default password: shell> mysql -uroot -p

6. Modify the root password: mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; (Note: don't forget the semicolon)

7. If you just The test database password may be relatively simple, such as: 123456, which cannot be verified by the mysql password. The reason is related to the default value of validate_password_policy:
validate_password_policy has the following values:
0 LOW Length
1 MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 STRONG Length; numeric, lowercase/uppercase, and special characters;dictionary file

The default is 1, which is MEDIUM, so the password must match the length, and must contain numbers, lowercase or uppercase letters, and special characters.
The solution is to modify the value of the validate_password_policy parameter:
mysql> set global validate_password_policy=0;
and then execute the above command to modify the password and it will be ok.

8. Then...it's not over yet. At this time, local access is completely fine, but when connecting remotely, it will throw: 1130-host... is not allowed to connect to this MySql server Solution:
(Allow all users with mypassword Connect this database for the password host)
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES; (refresh permissions, don't forget)
(allow ip to 192.168.1.2 The host with mypassword as the password connects to this database)
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.2' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; FLUSH
PRIVILEGES;
Check

again Now that the database installation is complete, you can connect.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326945504&siteId=291194637