The solution to the problem of not having permission to connect to the mysql database remotely: first execute the [mysql -uroot p password] statement in the bin directory of mysql to log in to the data; then execute use mysql, the code is [select host, user, password from user].
Solution to remote connection without permission to mysql database:
Problem description:
For the locally installed mysql database, there is no problem when writing localhost in the code and it starts normally. However, after changing the database address in the database connection URL to the local IP address, when starting the project, an error is reported:
Cause:java.sql.SQLException: null, message from server: " Host 'LAPTOP-OKH5Q67F' is not allowed to connect to this MySQL server"
It means that the server where the database is installed does not allow remote connections to the server where the project is deployed. That is, it is a permissions issue. Just modify the permissions. The modification method is.
The log is as shown:
Solution:
Execute in the bin directory of mysql: mysql - uroot -p password to log in to the data:
Execute use mysql;
select host,user,password from user;
You can see that user is root and host is localhost , indicating that mysql only allows local connections, then the external network and local software clients cannot connect.
Adjustment method:
Execution: update user set host='%' where user ='root';
Execute refresh permissions: flush privileges;
You can test the external network connection to the mysql server.
Related free learning recommendations:mysql database(Video)
The above is the detailed content of What should I do if I don't have permission to remotely connect to mysql database?. For more information, please follow other related articles on the PHP Chinese website!