Program Club

사용자 'root'@ 'localhost'에 대한 액세스가 거부되었습니다 (비밀번호 사용 : YES)-권한이 없습니까?

proclub 2020. 11. 6. 20:55
반응형

사용자 '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명령을 실행하고 완료 한 후에이 프로세스를 실행할 수 있습니다 .


내 사용자 권한이 마음에 들지 않았기 때문에 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으로 대체되었습니다.

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


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

sudo dpkg-reconfigure mysql-server-5.5

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

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


Ubuntu 서버에 Testlink를 설치하는 동안이 문제에 직면하여 다음 단계를 따랐습니다.

mysql -u root
use mysql;
update user set password=PASSWORD("root") where User='root';
flush privileges;
quit

이제 인스턴스를 중지하고 다시 시작하십시오.

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

mysql 5.7에서는 비밀번호 필드가 authentication_string으로 대체되었으므로 대신 이와 같은 작업을 수행합니다.

update user set authentication_string=PASSWORD("root") where User='root';

이 링크를 참조하십시오 MySQL 사용자 DB에 비밀번호 열이 없습니다-OSX에 MySQL 설치


루트 비밀번호를 재설정하는 가장 쉬운 방법은 다음과 같습니다.

  • mysqld --skip-grant-tables 옵션을 다시 시작하십시오 . 이를 통해 누구나 암호없이 모든 권한으로 연결할 수 있습니다. 이것은 안전하지 않기 때문에 원격 클라이언트가 연결하지 못하도록 --skip-networking과 함께 --skip-grant-tables를 사용하는 것이 좋습니다.

  • 다음 명령으로 mysqld 서버에 연결합니다.

  • shell> mysql mysql 클라이언트에서 다음 문을 실행합니다. 암호를 사용하려는 암호로 바꾸십시오.

  • mysql> UPDATE mysql.user SET Password = PASSWORD ( 'MyNewPass')-> WHERE User = 'root'; mysql> FLUSH PRIVILEGES;

  • 서버를 중지 한 다음 정상적으로 다시 시작합니다 (--skip-grant-tables 및 --skip-networking 옵션없이).

소스 Mysql 문서 및 개인 경험 :

http://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html


몇 시간 동안 사용자 'root'@ 'localhost'(암호 : YES)에 대한 액세스 거부 작업을 수행했는데 다음과 같은 해결책을 찾았습니다.

The answer to this problem was that in the my.cnf located within
/etc/mysql/my.cnf

the line was either 
bind-address = 127.0.0.1 
            (or)
bind-address = localhost
            (or)
bind-address = 0.0.0.0

I should prefer that 127.0.0.1

I should also prefer 0.0.0.0, it is more flexible 
because which will allow all connections

나는 우분투 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에 로그인 할 수 있습니다.

enter image description here


Try out the following steps to overcome this issue:

  1. Open terminal / command prompt and navigate to the bin folder of the MySQL installation folder. Then run the command mysqld --console.
  2. If you can see that line 171010 14:58:22 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled, after executing the above command from the command prompt.
  3. Then you need to check that the mysqld is either blocked by the Windows Firewall or another program.
  4. If it's blocked by Windows Firewall then need to unblock from it and save settings.
  5. To unblock the mysqld or mysql application, follow the below steps:
    1. Go to command prompt and type wf.msc to open the firewall settings.
    2. Click on Allow an app or feature through Windows Firewall.
    3. Check the mysqld or mysqld instances are available in the list and check the checkbox for the domain, public and private and save the settings.
  6. Return to the bin folder and try the command from step 1 again.
  7. It should work fine and not show any errors.

It should be possible to run the MySQL console without any problems now!


I resolved the same issue using next sql and restarting MySQL server:

update mysql.user set Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',Create_tablespace_priv='Y'
where user='root';

I don't think you have to escape the --init-file parameter:

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.6\\my.ini" --init-file=C:\\mysql-init.txt

Should be:

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.6\\my.ini" --init-file=C:\mysql-init.txt


for the above problem ur password in the system should matches with the password u have passed in the program because when u run the program it checks system's password as u have given root as a user so gives u an error and at the same time the record is not deleted from the database.

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
class Delete
{
    public static void main(String []k)
    {
        String url="jdbc:mysql://localhost:3306/student";

        String user="root";
        String pass="jacob234";
        try
        {
            Connection myConnection=DriverManager.getConnection(url,user,pass);
            Statement myStatement=myConnection.createStatement();
            String deleteQuery="delete from students where id=2";
            myStatement.executeUpdate(deleteQuery);
            System.out.println("delete completed");
        }catch(Exception e){
            System.out.println(e.getMessage());
        }
    }
}

Keep ur system password as jacob234 and then run the code.


I resolved the same issue by running Workbench as administrator.

...I guess it's because of restrictions on company computers, in my case...


With me was the same problem, but it was caused, because i was using the mysql server on 32 (bit) and the workbench was running on 64(bit) version. the server and the workbench need to has the same version.

xpress


For me i was using MYSQLWorkbench and the port was 3306 MAMP using 8889

참고URL : https://stackoverflow.com/questions/17975120/access-denied-for-user-rootlocalhost-using-password-yes-no-privileges

반응형