your programing

호스트 'xxx.xx.xxx.xxx'는이 MySQL 서버에 연결할 수 없습니다.

lovepro 2020. 10. 2. 23:03
반응형

호스트 'xxx.xx.xxx.xxx'는이 MySQL 서버에 연결할 수 없습니다.


이것은 매우 간단해야하지만 제 삶을 위해 작동하도록 할 수는 없습니다 .
내 MySQL 서버에 원격으로 연결하려고합니다.

다음으로 연결

mysql -u root -h localhost -p  

잘 작동하지만 시도

mysql -u root -h 'any ip address here' -p

오류와 함께 실패

ERROR 1130 (00000): Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server

에서 mysql.user테이블, 정확히 호스트 '%'와 다른 같은 호스트 'localhost를'을 가지고있는 사용자 '루트'에 대해 동일한 항목이 있습니다.

나는 현명하게 끝났고 어떻게 진행해야할지 모르겠다. 어떤 아이디어라도 환영합니다.


보안 예방 조치 일 수 있습니다. 새 관리자 계정을 추가해 볼 수 있습니다.

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     WITH GRANT OPTION;

Pascal과 다른 사람들이 언급했듯이 이러한 종류의 액세스 권한을 가진 사용자가 모든 IP에 대해 공개하는 것은 좋은 생각이 아닙니다. 관리 사용자가 필요한 경우 root를 사용하고 localhost에 그대로 둡니다. 다른 작업의 경우 필요한 권한을 정확히 지정하고 Pascal이 아래에서 제안한대로 사용자의 접근성을 제한합니다.

편집하다:

MySQL FAQ에서 :

액세스가 거부 된 이유를 알 수없는 경우 와일드 카드가 포함 된 호스트 값이있는 모든 항목 ( '%'또는 '_'문자가 포함 된 항목)을 사용자 테이블에서 제거하십시오. 매우 일반적인 오류는 Host = '%'및 User = 'some_user'로 새 항목을 삽입하는 것입니다. 이렇게하면 동일한 시스템에서 연결할 로컬 호스트를 지정할 수 있다고 생각합니다. 이것이 작동하지 않는 이유는 기본 권한에 Host = 'localhost'및 User = ''항목이 포함되어 있기 때문입니다. 해당 항목에는 '%'보다 구체적인 호스트 값 'localhost'가 있기 때문에 localhost에서 연결할 때 새 항목보다 우선적으로 사용됩니다! 올바른 절차는 Host = 'localhost'및 User = 'some_user'로 두 번째 항목을 삽입하거나 Host = 'localhost'및 User = '로 항목을 삭제하는 것입니다. '. 항목을 삭제 한 후 FLUSH PRIVILEGES 문을 실행하여 부여 테이블을 다시로드해야합니다. 5.4.4 절.“액세스 제어, 1 단계 : 연결 확인”을 참조하십시오.


phpMyAdmin 또는 명령 프롬프트를 통해 new MySQL User아래와 같이 권한 을 생성 하고 할당해야 Query prompt합니다.

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

네 가지 쿼리가 모두 완료되면 다음과 연결되어야합니다. username / password


내 오류 메시지는 비슷했고 루트를 사용하고 있었지만 ' 호스트 XXX는이 MySQL 서버에 연결할 수 없습니다 '라고 말했습니다 . 루트에 올바른 권한이 있는지 확인하는 방법은 다음과 같습니다.

내 설정 :

  • Ubuntu 14.04 LTS
  • MySQL v5.5.37

해결책

  1. 'etc / mysql / my.cnf'에서 파일을 엽니 다.
  2. 확인 :

    • 포트 (기본적으로 'port = 3306')
    • bind-address (기본적으로 이것은 'bind-address = 127.0.0.1'입니다. 모두에게 열려고 싶다면이 줄을 주석 처리하십시오. 제 예를 들어 실제 서버는 10.1.1.7에 있다고 말할 것입니다.)
  3. 이제 실제 서버의 MySQL 데이터베이스에 액세스합니다 (예를 들어 원격 주소는 포트 3306에서 'root'사용자로 123.123.123.123이고 데이터베이스 'dataentry'에 대한 권한을 변경하고 싶습니다. IP 주소, 포트 및 데이터베이스 이름을 변경해야합니다. 설정에)

    mysql -u root -p
    Enter password: <enter password>
    mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password';
    mysql>FLUSH PRIVILEGES;
    mysql>exit
    
  4. sudo 서비스 mysqld restart

  5. 이제 데이터베이스에 원격으로 연결할 수 있습니다. 예를 들어, MySQL Workbench를 사용하고 'Hostname : 10.1.1.7', 'Port : 3306', 'Username : root'를 입력하고 있습니다.

호스트 이름에서 사용자에게 액세스 권한을 부여해야합니다.

phpmyadmin에서 새 권한을 추가하는 방법입니다.

권한으로 이동> 새 사용자 추가

여기에 이미지 설명 입력

원하는 사용자 이름으로 모든 호스트선택하십시오.

여기에 이미지 설명 입력


다음 단계를 수행하십시오.

1) mysql에 연결

mysql -uroot -p

2) 사용자 생성

CREATE USER 'user'@'%' IDENTIFIED BY 'password';

3) 권한 부여

 GRANT ALL PRIVILEGES ON \*.\* TO 'user'@'%' WITH GRANT OPTION;

4) 플러시 권한

FLUSH PRIVILEGES;

이 메시지 *Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server는 MySQL 서버에서 MySQL 클라이언트로 보내는 응답입니다. 호스트 이름이 아닌 IP 주소를 반환하는 방법에 유의하십시오.

연결을 시도 mysql -h<hostname> -u<somebody> -p하고 IP 주소와 함께이 메시지를 반환하는 경우 MySQL 서버는 클라이언트에서 역방향 조회를 수행 할 수 없습니다. 이것은 MySQL 클라이언트를 그랜트에 매핑하는 방법이기 때문에 중요합니다.

nslookup <mysqlclient>MySQL 서버에서 할 수 있는지 확인하십시오 . 그래도 작동하지 않으면 DNS 서버에 항목이없는 것입니다. 또는 MySQL 서버의 HOSTS 파일에 항목을 넣을 수 있습니다 ( <ipaddress> <fullyqualifiedhostname> <hostname><-여기서 순서가 중요 할 수 있음).

MySQL 클라이언트의 역방향 조회를 허용하는 내 서버의 호스트 파일 항목이 바로이 문제를 해결했습니다.


그랜트 테이블을 수동으로 수정하는 경우 (INSERT, UPDATE 등을 사용하여) FLUSH PRIVILEGES서버에 그랜트 테이블을 다시로드하도록 지시 하는 문을 실행해야합니다 .

PS : 나는 할 수 있도록 권하고 싶지 않다 어떤 호스트가 연결하는 모든 사용자 (특히 아니라 root사용). 클라이언트 / 서버 애플리케이션에 mysql을 사용하는 경우 서브넷 주소를 선호합니다. 웹 서버 또는 애플리케이션 서버와 함께 mysql을 사용하는 경우 특정 IP를 사용하십시오.


간단한 방법 :

Grant All Privileges ON *.* to 'USER_NAME'@'%' Identified By 'YOUR_PASSWORD'; 

그때

FLUSH PRIVILEGES;

끝난!


MySql의 GUI 도구 (SQLyog)에서 제공하는 인터페이스를 사용하십시오.

사용자 관리자를 클릭하십시오. 여기에 이미지 설명 입력

이제 다른 원격 PC에 대한 액세스 권한을 부여하려면 아래 그림과 같이 호스트 필드 값이 % (와일드 카드)인지 확인하십시오.

여기에 이미지 설명 입력


Most of the answers here show you creating users with two host values: one for localhost, and one for %.

Please note that except for a built-in localhost user like root, you don't need to do this. If you simply want to make a new user that can log in from anywhere, you can use

CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
GRANT <whatever privileges are appropriate> ON <relevant tables> TO myuser;

and it will work just fine. (As others have mentioned, it's a terrible idea to grant administrative privileges to a user from any domain.)


simple way is to login to phpmyadmin with root account , there goto mysql database and select user table , there edit root account and in host field add % wild card . and then through ssh flush privileges

 FLUSH PRIVILEGES;

If this is a recent mysql install, then before changing anything else, try simply to execute this command and then try again:

flush privileges;

This alone fixes the issue for me on Ubuntu 16.04, mysql 5.7.20. YMMV.


Just find a better way to do that from your hosting control panel (I'm using DirectAdmin here)

simply go to the target server DB in your control panel, in my case: MySQL management -> select your DB -> you will find: "Access Hosts", simply add your remote host here and its working now! 여기에 이미지 설명 입력

I guess there is a similar option on other C.panels like plesk, etc..

I'm hope it was helpful to you too.


Well what you can do is just open mysql.cfg file and you have to change Bind-address to this

bind-address = 127.0.0.1

and then Restart mysql and you will able to connect that server to this.

Look this you can have idea form that.

this is real sol


If you happen to be running on Windows; A simple solution is to run the MySQL server instance configuration wizard. It is in your MYSQL group in the start menu. On the second from last screen click the box that says "allow root access from remote machines".


CPANEL solution

Go to Cpanel, look for Remote MySQL. Add the the IP in the input field:

Host (% wildcard is allowed)

Comment to remember what IP that is. That was it for me.


On the off chance that someone facing this issue is experiencing it from within SQLyog, this happened:

I had connected to the remote database (from within SQLyog) and worked for some hours. Afterwards I left the system for some minutes, then came back to continue my work - ERROR 1130 ! Nothing I tried worked; Restarting SQLyog didn't fix it. Then I restarted the system - it still didn't work.

So I tried connecting from the terminal - it worked. Then retried it on SQLyog ... and it worked. I can't explain it other than 'random computer quirkiness', but I think it might help someone.


I was also facing the same issue. I resolved it in 2 min for me I just white list ip through cpanel

Suppose you are trying to connect database of server B from server A. Go to Server B Cpanel->Remote MySQL-> enter Server A IP Address and That's it.


This answer might help someone...

All these answers didnt help, then I realised I forgot to check one crucial thing.. The port :)

I have mysql running in a docker container running on a different port. I was pointing to my host machine on port 3306, which I have a mysql server running on. My container exposes the server on port 33060. So all this time, i was looking at the wrong server! doh!


This working for DirectAdmin;

  1. Go to your DirectAdmin.
  2. Go to your MySQL Management.
  3. Select your database.
  4. Under your Accesse Host tab, there is a field. You should fill this field by xxx.xx.xxx.xx.
  5. Click on Add Host.

Finished. Now you can access to this DB by your your_database_username & your_database_password.
So Simple!


CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

this error because no password to the root , and this Maybe occurred with you when you trying to connect from outside .


if you are trying to execute mysql query withouth defining connectionstring, you will get this error.

Probably you forgat to define connection string before execution. have you check this out? (sorry for bad english)


Problem: root@localhost is unable to connect to a fresh installation of mysql-community-server on openSUSE 42.2-1.150.x86_64. Mysql refuses connections - period.

Solution:

$ ls -l /var/lib/mysql/mysql/user.*
-rw-rw---- 1 mysql mysql     0 Apr 29 19:44 /var/lib/mysql/mysql/user.MYD
-rw-rw---- 1 mysql mysql  1024 Apr 29 19:44 /var/lib/mysql/mysql/user.MYI
-rw-rw---- 1 mysql mysql 10684 Apr 29 19:44 /var/lib/mysql/mysql/user.frm

File user.MYD has 0 size (really ?!). I copied all 3 files from another working system.

$ /usr/sbin/rcmysql stop
$ cd /var/lib/mysql/mysql/
$ scp root@othersytem:/var/lib/mysql/mysql/user.* ./
$ /usr/sbin/rcmysql start
$ cd -
$ mysql -u root -p

I was able to log in. Then, it was just a matter of re-applying all schema privileges. Also, if you disabled IPv6, re-enable it temporary so that root@::1 account can also work.


여기에 나와있는 모든 답변이 제 경우에는 작동하지 않았으므로 나중에 다른 사용자에게 도움이 될 수 있습니다. 이것은 MySQL뿐만 아니라 우리 코드에서도 문제가 될 수 있습니다.

사용하는 경우 VB.NET

이 코드 대신 :

 Dim server As String = My.Settings.DB_Server
 Dim username As String = My.Settings.DB_Username
 Dim password As String = My.Settings.DB_Password
 Dim database As String = My.Settings.DB_Database

 MysqlConn.ConnectionString = "server=" & server & ";" _
 & "user id=" & username & ";" _
 & "password=" & password & ";" _
 & "database=" & database

 MysqlConn = New MySqlConnection()

MysqlConn = New MySqlConnection()첫 번째 줄로 이동해야합니다 . 그래서 이렇게 될거야

 MysqlConn = New MySqlConnection()

 Dim server As String = My.Settings.DB_Server
 Dim username As String = My.Settings.DB_Username
 Dim password As String = My.Settings.DB_Password
 Dim database As String = My.Settings.DB_Database

 MysqlConn.ConnectionString = "server=" & server & ";" _
 & "user id=" & username & ";" _
 & "password=" & password & ";" _
 & "database=" & database

참고 URL : https://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server

반응형