원격 MySQL 연결 활성화 : ERROR 1045 (28000) : 사용자의 액세스 거부
Windows XP에서 실행되는 MySQL 5.1.31
로부터 지역 다음과 같이 MySQL 서버 (192.168.233.142) 내가 루트로 연결할 수 있습니다 :
>mysql --host=192.168.233.142 --user=root --password=redacted
A로부터 원격 컴퓨터 (192.168.233.163), I는 MySQL의 포트가 열려 있음을 볼 수있다 :
# telnet 192.168.233.142 3306
Trying 192.168.233.142...
Connected to 192.168.233.142 (192.168.233.142).
그러나 원격 컴퓨터 에서 mysql에 연결하려고하면 다음과 같은 메시지가 나타납니다.
# mysql --host=192.168.233.142 --user=root --password=redacted
ERROR 1045 (28000): Access denied for user 'root'@'192.168.233.163' (using password: YES)
mysql.user에는 2 개의 항목 만 있습니다.
Host User Password
--------------------------------------
localhost root *blahblahblah
% root [same as above]
원격 액세스를 활성화하려면 무엇을 더해야합니까?
편집하다
아래 Paulo가 제안한 것처럼 %에 대한 mysql.user 항목을 IP 특정 항목으로 바꾸려고 했으므로 이제 사용자 테이블은 다음과 같습니다.
Host User Password
------------------------------------------
localhost root *blahblahblah
192.168.233.163 root [same as above]
그런 다음 컴퓨터를 다시 시작했지만 문제가 지속됩니다.
이것을 루트로 넣어야합니다.
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD' with grant option;
;
여기서 IP는 액세스를 허용하려는 IP이고 USERNAME은 연결에 사용하는 사용자이며 PASSWORD는 관련 비밀번호입니다.
IP에서 액세스를 허용하려면 IP %
대신
그리고 당신은 넣어
FLUSH PRIVILEGES;
또는 mysql 서버를 다시 시작하면됩니다.
내가 할 때까지 원격 액세스 권한을 부여 한 후에도 같은 오류가 발생했습니다.
에서 /etc/mysql/my.cnf
최신 버전의 mysql에서 파일의 위치는 /etc/mysql/mysql.conf.d/mysqld.cnf
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
(이 줄을 주석으로 처리하십시오. bind-address = 127.0.0.1
)
그런 다음를 실행하십시오 service mysql restart
.
MySQL 서버에서는 기본적으로 원격 액세스가 비활성화되어 있습니다. 사용자에게 원격 액세스를 제공하는 프로세스는 다음과 같습니다.
- 내 SQL bin 폴더로 이동하거나 다음에 추가하십시오.
PATH
- 루트
mysql -uroot -proot
(또는 루트 비밀번호가 무엇이든) 로 루트에 로그인하십시오 . - 성공하면 얻을 것이다
mysql>
- 해당 사용자에게 모두 액세스 권한을 부여하십시오.
GRANT ALL PRIVILEGES ON *.* TO 'username'@'IP' IDENTIFIED BY 'password';
여기서 IP는 IP 주소를 원격으로 액세스 할 수있는 경우 원격 액세스를 허용하려는 %
IP 주소입니다.
예:
C:\Users\UserName> cd C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin
C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.27 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.25 sec)
이것은 다른 사용자를위한 것입니다.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'testUser'@'%' IDENTIFIED BY 'testUser';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
이것이 도움이되기를 바랍니다.
파울로의 도움으로 해결책을 찾게되었습니다. 다음의 조합이었습니다.
- 암호는 달러 기호를 포함
- 리눅스 쉘에서 연결하려고했습니다.
bash 쉘은 달러 기호를 환경 변수 로 확장 하기 위한 특수 문자로 취급 하므로 백 슬래시로 이스케이프 처리해야합니다. 또한 달러 기호가 암호의 마지막 문자 인 경우에는이 작업을 수행 할 필요가 없습니다 .
예를 들어, 비밀번호가 "pas $ word"인 경우 Linux bash에서 다음과 같이 연결해야합니다.
# mysql --host=192.168.233.142 --user=root --password=pas\$word
방화벽이 있습니까? 포트 3306이 열려 있는지 확인하십시오.
On windows , by default mysql root account is created that is permitted to have access from localhost only unless you have selected the option to enable access from remote machines during installation .
creating or update the desired user with '%' as hostname .
example :
CREATE USER 'krish'@'%' IDENTIFIED BY 'password';
Try to
flush privileges
again.Try to restart server to reload grants.
Try create a user with host "192.168.233.163". "%" appears to not allow all (it's weird)
In my case I was trying to connect to a remote mysql server on cent OS. After going through a lot of solutions (granting all privileges, removing ip bindings,enabling networking) problem was still not getting solved.
As it turned out, while looking into various solutions,I came across iptables, which made me realize mysql port 3306 was not accepting connections.
Here is a small note on how I checked and resolved this issue.
Checking if port is accepting connections:
telnet (mysql server ip) [portNo]
Adding ip table rule to allow connections on the port:
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
Would not recommend this for production environment, but if your iptables are not configured properly, adding the rules might not still solve the issue. In that case following should be done:
service iptables stop
Hope this helps.
if you are using dynamic ip just grant access to 192.168.2.% so now you dont have to worry about granting access to your ip address every time.
I was struggling with remote login to MYSQL for my Amazon EC2 Linux instance. Found the solution was to make sure my security group included an inbound rule for MySQL port 3306 to include my IP address (or 0.0.0.0/0 for anywhere). Immediately could connect remotely as soon as I added this rule.
New location for mysql config file is
/etc/mysql/mysql.conf.d/mysqld.cnf
MySQL ODBC 3.51 Driver is that special characters in the password aren't handled.
"Warning – You might have a serious headache with MySQL ODBC 3.51 if the password in your GRANT command contains special characters, such as ! @ # $ % ^ ?. MySQL ODBC 3.51 ODBC Driver does not support these special characters in the password box. The only error message you would receive is “Access denied” (using password: YES)" - from http://www.plaintutorials.com/install-and-create-mysql-odbc-connector-on-windows-7/
The user/host combination may have been created without password.
I was assuming that when adding a new host for an existing user (using a GUI app), the existing password would also be used for the new user/host combination.
I could log in with
mysql -u username -p PASSWORD
locally, but not from IPADDRESS with
mysql -u --host=HOST -p PASSWORD
(I could actually log in from IPADDRESS without using a password)
mysql -u --host=HOST
Setting the password allowed access:
set password for '<USER>'@'<IPADDRESS>' = '<PASSWORD>';
'Programming' 카테고리의 다른 글
텍스트 상자가 포커스를 잃을 때까지 jQuery 텍스트 상자 변경 이벤트가 발생하지 않습니까? (0) | 2020.07.05 |
---|---|
파이썬에서 숫자의 모든 요소를 찾는 가장 효율적인 방법은 무엇입니까? (0) | 2020.07.05 |
목록을 더 작은 목록으로 나누기 (반으로 분할) (0) | 2020.07.05 |
VB.NET에서 인라인 목록 초기화 (0) | 2020.07.05 |
Typescript의 ES6 맵 (0) | 2020.07.05 |