What should I do if I don't have permission to remotely connect to mysql database?

coldplay.xixi
Release: 2020-10-19 10:58:54
Original
3700 people have browsed it

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].

What should I do if I don't have permission to remotely connect to mysql database?

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:

What should I do if I dont have permission to remotely connect to mysql database?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!