Installation environment: CentOS7 64-bit MINI version, install MySQL5.7
Download the YUM source rpm installation package in the MySQL official website: https://dev.mysql.com/downloads/repo/yum/
# Download the mysql source installation package
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# Install mysql source
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
Check whether the mysql source is installed successfully
shell> yum repolist enabled | grep "mysql.*-community.*"
Seeing the picture above indicates a successful installation.
shell> yum install mysql-community-server
shell> systemctl start mysqld
View the startup status of MySQL
shell> systemctl status mysqld
shell> systemctl enable mysqld
shell> systemctl daemon-reload
After mysql is installed, a default password is generated for root in the /var/log/mysqld.log file. Find the default root password in the following way, and then log in to mysql to modify it:
shell> grep 'temporary password' /var/log/mysqld.log
shell> mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
or
mysql>set password for'root'@'localhost'=password('MyNewPass4!');
Note: mysql5.7 installs the password security check plugin (validate_password) by default. The default password check policy requires that the password must contain uppercase and lowercase letters, numbers and special symbols, and the length cannot be less than 8 characters. Otherwise, it will prompt ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error, as shown in the following figure:
**By default, MySQL only allows the root account to log in locally. If you want to connect to MySQL remotely, you must enable the root user to allow remote connections, or add an account that allows remote connections. **
mysql -u root -p
Use mysql library: use mysql
Query information: select user,host from user
In the host field, localhost means that only the local machine is allowed to access. To realize remote connection, you can change the host of the root user to %,% means that any host is allowed to access. If you need to set to allow only specific ip access, you should change to the corresponding ip .
update user set host="%" where user="root"
flush privileges
Finally, if you connect remotely in Navicat under windows, no error will be reported.
Recommended Posts