[mysql] 사용자 ‘root’@ ‘localhost’에 대한 액세스 거부 (암호 사용 : YES)-권한이 없습니까?

이 오류가 계속 발생합니다.

mySQL Workbench를 사용하고 있으며 루트의 스키마 권한이 null이라는 것을 발견했습니다. 특권이 전혀 없습니다.

내 서버가 사용되는 플랫폼에서 문제가 발생했으며 이것은 모두 갑작스러운 문제였습니다.

root@127.0.0.1은 분명히 많은 액세스 권한을 가지고 있지만 그렇게 로그인했지만 어쨌든 localhost에 할당합니다 -localhost 에는 권한이 없습니다.

내가 좋아하는 몇 가지했던 FLUSH HOSTS, FLUSH PRIVILEGES등하지만 나 인터넷에서 어떤 성공을 발견했다.

루트 액세스 권한을 어떻게 되 찾을 수 있습니까? 주변을 둘러 볼 때 사람들이 “액세스 권한이있을”것으로 기대하지만 액세스 권한이 없어서 명령 줄이나 어떤 것도 나 GRANT자신도 들어갈 수 없기 때문에 실망 스럽 습니다.

실행할 때 SHOW GRANTS FOR root이것이 내가 대가로 얻는 것입니다.

오류 코드 : 1141. ‘%’호스트의 ‘root’사용자에 대해 정의 된 권한이 없습니다.



답변

루트 암호 재설정 지침을 사용하십시오 . 그러나 루트 암호를 재설정하는 대신 mysql.user 테이블에 레코드를 강제로 삽입 할 것입니다.

init 파일에서 대신 이것을 사용하십시오.

INSERT INTO mysql.user (Host, User, Password) VALUES ('%', 'root', password('YOURPASSWORD'));
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;


답변

MySql 5.7. +에서 동일한 문제가있는 경우 :

Access denied for user 'root'@'localhost'

MySql 5.7은 기본적으로 소켓에 연결할 수 있기 때문에 sudo mysql. sql을 실행하는 경우 :

SELECT user,authentication_string,plugin,host FROM mysql.user;

그러면 볼 수 있습니다.

+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             |                                           | auth_socket           | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *497C3D7B50479A812B89CD12EC3EDA6C0CB686F0 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)

루트 및 비밀번호로 연결을 허용하려면 다음 명령을 사용하여 테이블의 값을 업데이트하십시오.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Current-Root-Password';
FLUSH PRIVILEGES;

그런 다음 select 명령을 다시 실행하면 변경된 것을 볼 수 있습니다.

+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             | *2F2377C1BC54BE827DC8A4EE051CBD57490FB8C6 | mysql_native_password | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *497C3D7B50479A812B89CD12EC3EDA6C0CB686F0 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)

그리고 그게 다야. sudo mysql_secure_installation명령을 실행하고 완료 한 후에이 프로세스를 실행할 수 있습니다 .

mariadb의 경우

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('manager');

비밀번호를 설정합니다. https://mariadb.com/kb/en/set-password/ 에서 자세히 알아 보기


답변

내 사용자 권한이 마음에 들지 않았기 때문에 SUDO. (bash << sudo set user and password) (이것은 root의 사용자 이름을 제공하고 암호를 아무것도 설정하지 않음) (Mac에서)

sudo mysql -uroot -p


답변

다음 명령을 시도하십시오.

~$ sudo /etc/init.d/mysql stop
~$ sudo mysqld_safe --skip-grant-tables &
~$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

mysql> use mysql;

mysql> update user set password=PASSWORD("root") where User='root';

mysql> flush privileges;

mysql> quit

~$ sudo /etc/init.d/mysql stop

Stopping MySQL database server: mysqld

STOPPING server from pid file /var/run/mysqld/mysqld.pid

mysqld_safe[6186]: ended

[1]+  Done                    mysqld_safe --skip-grant-tables

~$ sudo /etc/init.d/mysql start

~$ mysql -u root -p

* MySQL Community Server 5.6.35 is started
~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 


답변

mysql 5.7 이상 버전에서 오류가 발생하는 사람들을 위해-

Access denied for user 'root'@'localhost' (using password: YES)
  1. 새 터미널 열기

  2. sudo /etc/init.d/mysql stop
    … MySQL Community Server 5.7.8-rc가 중지되었습니다.

  3. sudo mysqld_safe --skip-grant-tables &
    이것은 모든 부여 수준 권한을 건너 뛰고 안전 모드에서 mysql을 시작합니다. 때때로 프로세스가

grep : 쓰기 오류 : Broken pipe 180102 11:32:28 mysqld_safe Logging to ‘/var/log/mysql/error.log’.

Ctrl + Z 또는 Ctrl + C를 눌러 프로세스를 중단하고 종료합니다.

  1. mysql -u root

MySQL 모니터에 오신 것을 환영합니다. 명령은; 또는 \ g. MySQL 연결 ID는 2 서버 버전 : 5.7.8-rc MySQL Community Server (GPL)입니다.

Copyright (c) 2000, 2015, Oracle 및 / 또는 그 계열사. 판권 소유.

Oracle은 Oracle Corporation 및 / 또는 그 계열사의 등록 상표입니다. 다른 이름은 해당 소유자의 상표 일 수 있습니다.

‘help;’를 입력하십시오. 또는 ‘\ h’로 도움을 받으세요. 현재 입력 명령문을 지우려면 ‘\ c’를 입력하십시오.

  1. mysql> use mysql;

테이블 및 열 이름 완성을위한 테이블 정보 읽기이 기능을 해제하여 -A를 사용하여 더 빨리 시작할 수 있습니다.

데이터베이스 변경

  1. mysql> update user set authentication_string=password('password') where user='root';
    Query OK, 4 개 행 영향, 1 개 경고 (0.03 초) 일치 된 행 : 4 개 변경됨 : 4 개 경고 : 1 개

  2. mysql> flush privileges;
    쿼리 OK, 영향을받는 행 0 개 (0.00 초)

  3. mysql> quit
    안녕

  4. sudo /etc/init.d/mysql stop

..180102 11:37:12 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended. * MySQL Community Server 5.7.8-rc가 중지됨 arif @ ubuntu : ~ $ sudo /etc/init.d/mysql start .. * MySQL Community Server 5.7.8-rc가 시작됨

  1. mysql -u root -p

    암호를 입력:

    MySQL 모니터에 오신 것을 환영합니다. 명령은; 또는 \ g. MySQL 연결 ID는 2 서버 버전 : 5.7.8-rc MySQL Community Server (GPL)입니다.

mysql 5.7+ 버전 이후에는 열 암호가 mysql.user 테이블의 이름 authentication_string으로 대체되었습니다.

이 단계가 누구에게나 도움이되기를 바랍니다. 감사합니다.


답변

나는 우분투 18을 사용하고 있었고 다음 명령으로 MySQL (password : root)을 설치했습니다.

sudo apt install mysql-server
sudo mysql_secure_installation

일반 우분투 사용자로 로그인하려고 할 때이 문제가 발생했습니다.

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

하지만 수퍼 유저를 통해 MySQL에 로그인 할 수있었습니다. 다음 명령을 사용하여 일반 사용자를 통해 로그인 할 수있었습니다.

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
exit;

그러면 일반 계정으로 Mysql에 로그인 할 수 있습니다.

여기에 이미지 설명 입력


답변

Linux 시스템에서 루트 비밀번호를 재설정하는 간단한 방법 :

sudo dpkg-reconfigure mysql-server-5.5

액세스가 거부 된 다른 이유를 확인하세요.

https://dev.mysql.com/doc/refman/5.7/en/problems-connecting.html