CENTOS installation MySQL correct method

1. Official installation document

http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

< h3>2, download Mysql yum package

http://dev.mysql.com/downloads/repo/yum/

 Share the picture

Download it locally and then Upload to the server, or use wget to download directly

wget http:< span class="hljs-comment">//repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm

3. Install software source

Replace platform-and-version-specific-package-name with the rpm name you downloaded p>

sudo rpm -Uvh platform-and-version-specific-package-name.rpm 

For example

rpm -Uvh  mysql57-community-release-el7- 10.noarch.rpm
share image

4. Install mysql server

yum install -y mysql-community-server

If the network environment is not very good, can I make a cup of tea after executing the command? ?Or kill a game of glory (you can download the corresponding rpm package yourself or directly download the...bundle.tar compressed package)

5. First start mysql

service mysqld start (restart is restart, it is best to add lower_case_table_names=1 Go to the line under [mysqld] and restart MySQL. This is for compatibility with windows. Also, add default-character-set=utf8)
systemctl start mysqld.service (this is automatically output after the above steps are executed, my full name here is: Redirecting to /bin/systemctl start mysqld.service)
and then go back [.....]#

6. Then check the running status of mysql

service mysqld status
systemctl < span class="hljs-selector-tag">status mysqld.service (also automatically output by the system , My full name here is: Redirecting to /bin/systemctl status mysqld.service)
Then it will output a large paragraph about MySQL status information:

mysqld.service-MySQL Server
Loaded: loaded ( /usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 2017-07-30 08:24:29 CST; 26s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 58507 ExecStart=/usr/sbin/mysqld --daemonize --pid -file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 58426 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 58511 (mysqld)
CGroup: /system.slice/mysqld.service
└─58511 / usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/my...

July 30 08:24:21 localhost.localdomain systemd[1]: Starting MySQL Server...
July 30 08:24:29 localhost.localdomain systemd[1]: Started MySQL Server. (Note this sentence, indicating that the MySQL service is already running at this time)

7. Modify the temporary password

After Mysql5.7 is installed by default, root has a password.

7.1 Get the temporary password of MySQL

In order to strengthen security, MySQL 5.7 randomly generates a password for the root user. In the error log, the location of the error log , If the RPM package is installed, the default is /var/log/mysqld.log.
You can view the temporary password only once mysql has been started

grep 'temporary password' /var/log/mysqld. log (If MySQL has been installed before, there may be multiple passwords here. Use the last one. Note that this password is Can be pasted)
share picture

The password here is YdsGaxOq>2n!< /code>

7.2 Login and change password

Use the default password to log in

 mysql -uroot -p (This is a MySQL command to log in to the root user with a password)

After logging in to the server with this password, you must immediately change the password and perform some database operations, otherwise The following error will be reported:

mysql> select @@log_error;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql>

Modify the password (note that it is best to have after the operation after login; end)

ALTER USER  'root'@'localhost' IDENTIFIED BY 'root123';< /span>

If the password setting is too simple, the following prompt will appear

 Share picture

< /div>

How to solve ERROR 1819 (HY000): Your password does not satisfy the current policy requirements? The solution is directly provided here. There are detailed instructions at the end of the article.

Two global parameters must be modified:
First, modify the value of the validate_password_policy parameter

mysql>set global < /span>validate_password_policy=0;

Change the length of the password< /p>

set global  validate_password_length=1;

Execute the modification again The password will do

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123' ; (ALTER etc. can be written in lowercase) 

8. Authorize other machines to log in

 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' < span class="hljs-keyword">IDENTIFIED BY < span class="hljs-string">'yourpassword' WITH GRANT OPTION; < span class="hljs-keyword">FLUSH PRIVILEGES; span>

9. Detailed instructions on password settings

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements