Solution: 1. Modify the "my.cnf" file and add "#" in front of "bind-address = 127.0.0.1" to comment it out; 2. Add "skip-external" to the file -lockingskip-name-resolve"; 3. Use "service mysql restart" to restart the mysql service.
The operating environment of this tutorial: linux7.3 system, mysql8.0.22 version, Dell G3 computer.
Solution:
1. Modify the mysql file
In the console Enter, enter the mysql directory,
sudo su //进入root权限cd /etc/mysql
open the my.cnf file, find bind-address = 127.0.0.1 and comment it out with # in front, as follows:
#bind-address = 127.0.0.1
2, Then add the following code
skip-external-lockingskip-name-resolve
If it cannot be found in the my.cnf file #bind-address = 127.0.0.1 as shown in the picture:
Then go to the second path /etc/mysql/mysql.conf.d/ folder to open the mysqld.cnf file and modify it.
3. Restart the mysql service
service mysql restart
Expand knowledge:
By the way, let me tell you about the connection encountered is not allowed to connect to this MySQL server error solution;
1. Enter mysql -uroot -p password on the console to enter mysql
(2. Enter use mysql; to enter the mysql database
3. Enter update user set host='%' where user='root' ; to allow access through IP.) Note: The method in brackets allows everyone to connect, and it is easy to be hacked by others, so you need to Set up specified IP access. The specific method is as follows:
Directly enter:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'要指定的IP地址' IDENTIFIED BY '设置的密码' WITH GRANT OPTION;
You can also update the host to % first, and then update the host to your own IP through the graphical interface (SqlYog, workbench, etc.).
4. Continue to enter flush privileges; Remember, no matter which method you choose above, you must perform this step to update the database user permissions. Very important! ! !
5. Then reconnect and the problem will be solved.
Recommended learning: mysql video tutorial
The above is the detailed content of How to solve the 2003 error of mysql in linux. For more information, please follow other related articles on the PHP Chinese website!