The pitfalls encountered by mysql remote connection

Environment: kali linux, marridb
Problem: mysql -uroot -ppass, mysql -h 127.0.0.1 -uroot -ppass, mysql -h localhost -uroot -ppass can connect to the database, but mysql -h 192.168.240.132 -uroot -ppass cannot connect

Solution:
1. The remote connection user is not set (I have set it, and I am worried that the brothers who read the article did not set it)
1. Set the remote connection user:
the % in it means that any address can be connected. If you only want to specify an ip, then Just write the corresponding ip
mysql>GRANT ALL PRIVILEGES ON . TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
2. Refresh
mysql>flush privileges;
2. The connection address is not modified in the configuration
file The situation exists in my.conf, mainly looking for the mysqld option, but mine may be relatively new or relatively low, find the configuration file 50-server.cnf under /etc/mysql/mariadb.conf.d, and set bind-address = 127.0 Change .0.1 to bind-address = 0.0.0.0
and restart the service to connect
insert image description hereinsert image description here

Guess you like

Origin blog.csdn.net/weixin_42380348/article/details/115138086