모든 호스트에서 MySQL 루트 액세스
원격 우분투 컴퓨터에 MySQL 서버를 설치했습니다. root
사용자는에 정의 된 mysql.user
테이블이 방법 :
mysql> SELECT host, user, password FROM user WHERE user = 'root';
+------------------+------+-------------------------------------------+
| host | user | password |
+------------------+------+-------------------------------------------+
| localhost | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| ip-10-48-110-188 | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 127.0.0.1 | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| ::1 | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------------------+------+-------------------------------------------+
root
표준 mysql
클라이언트를 사용하여 동일한 원격 컴퓨터 명령 줄 인터페이스에서 사용자와 액세스 할 수 있습니다 . 이제 인터넷의 모든 호스트에서 루트 액세스 를 허용 하고 싶습니다 . 따라서 다음 행을 추가하려고했습니다 (열을 제외하고 이전 덤프의 첫 번째 행과 정확히 똑같습니다 host
).
mysql> SELECT host, user, password FROM user WHERE host = '%';
+------------------+------+-------------------------------------------+
| host | user | password |
+------------------+------+-------------------------------------------+
| % | root | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------------------+------+-------------------------------------------+
그러나 내 개인 PC의 클라이언트는 계속 나에게 말합니다 (서버 IP가 가려졌습니다).
SQL 오류 (2003) : '46 .xxx '에서 MySQL 서버에 연결할 수 없음 (10061)
인증 오류인지 네트워크 오류인지 알 수 없습니다. 서버 방화벽 에서 0.03.0.0/0 포트 3306 / TCP 를 사용하도록 설정했습니다 .
이 과정에는 두 단계가 있습니다.
a) 권한을 부여하십시오. 루트 사용자는 'password'
현재 루트 비밀번호 로 다음을 대체 하여 실행 하십시오.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
b) 모든 주소에 바인딩
가장 쉬운 방법은 파일 에서 줄 을 주석 처리하는 것입니다my.cnf
.
#bind-address = 127.0.0.1
mysql을 다시 시작하십시오.
service mysql restart
기본적으로 로컬 호스트에만 바인드되지만 라인을 주석 처리하면 찾은 모든 인터페이스에 바인드됩니다. 라인을 주석 처리하는 것은와 같습니다 bind-address=*
.
mysql 서비스가 바인딩 된 위치를 확인하려면 루트로 실행하십시오.
netstat -tupan | grep mysql
우분투 16 업데이트 :
구성 파일은 (현재)
/etc/mysql/mysql.conf.d/mysqld.cnf
(적어도 표준 우분투 16에서)
다음 쿼리를 실행하십시오.
use mysql;
update user set host='%' where host='localhost'
참고 : 프로덕션 용도로는 권장되지 않습니다.
때때로
바인드 주소 = 127.0.0.1
해야한다
바인드 주소 = *
Raspbian에서 실행중인 MariaDB-bind-address가 포함 된 파일을 정확히 찾아 내기가 어렵습니다. MariaDB에는 주제에 대해 도움이되지 않는 정보 가 있습니다.
나는 사용했다
# sudo grep -R bind-address /etc
그 빌어 먹을 곳을 찾을 수 있습니다.
또한 위의 모든 사람들이 지적한 것처럼 mysql에서 권한과 호스트를 설정해야했습니다.
또한 내 Raspberry Pi에 원격 연결하기 위해 3306 포트를 여는 데 재미있는 시간을 보냈습니다 . 마침내 iptables-persistent를 사용했습니다 .
이제 모두 잘 작동합니다.
MYSQL 8.0-mysql 명령 행 클라이언트 열기
*. *를 'root'@ 'localhost'에 GRANT ALL PRIVILEGES ON;
mysql
업데이트 사용 mysql.user SET host = '%'WHERE user = 'root';
MySQL 서비스를 다시 시작하십시오
if you have many networks attached to you OS, yo must especify one of this network in the bind-addres from my.conf file. an example:
[mysqld]
bind-address = 127.100.10.234
this ip is from a ethX configuration.
In my case the "bind-address" setting was the problem. Commenting this setting in my.cnf
did not help, because in my case mysql set the default to 127.0.0.1 for some reason.
To verify what setting MySql is currently using, open the command line on your local box:
mysql -h localhost -u myname -pmypass mydb
Read out the current setting:
Show variables where variable_name like "bind%"
You should see 0.0.0.0 here if you want to allow access from all hosts. If this is not the case, edit your /etc/mysql/my.cnf
and set bind-address under the [mysqld] section:
bind-address=0.0.0.0
Finally restart your MySql server to pick up the new setting:
sudo service mysql restart
Try again and check if the new setting has been picked up.
mysql_update
is what you need.
I don't know why anyone would follow the more complex ways of correcting this issue, when MySql graciously built a tool that already does this...
참고URL : https://stackoverflow.com/questions/11223235/mysql-root-access-from-all-hosts
'IT story' 카테고리의 다른 글
Windows 작업 스케줄러로 배치 파일 실행 (0) | 2020.06.26 |
---|---|
Java에서 toString 메소드를 사용하여 int 배열을 String으로 변환하는 방법 (0) | 2020.06.26 |
ES6 +에서 두 개의 자바 스크립트 객체를 어떻게 병합합니까? (0) | 2020.06.26 |
EntityType에 키 정의 오류가 없습니다. (0) | 2020.06.26 |
여러 개의 인수로 함수를 적용하여 새 팬더 열 만들기 (0) | 2020.06.26 |