source

Mysql은 sudo와 함께 작동하지만 그렇지 않습니다.(ubuntu 16.04, mysql 5.7.12-0ubuntu1).1)

itover 2023. 1. 15. 10:23
반응형

Mysql은 sudo와 함께 작동하지만 그렇지 않습니다.(ubuntu 16.04, mysql 5.7.12-0ubuntu1).1)

있습니다Ubuntu 16.04,그리고.Mysql 5.7.12-0ubuntu1.1. 입력할 때:

sudo mysql -u root

mysql 콘솔에 로그인 할 수 있지만 입력 시sudo:

mysql -u root

에러가 표시된다.

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

설치 및 삭제 시 문제가 발생하였습니다.MariaDB그때 기억이 나네요PostgreSQL데이터베이스에 로그인하는 UNIX 사용자도 중요하지만, 이것을 어떻게 처리하는지는,Mysql?


이 문제는 다음과 같이 해결했습니다.

https://askubuntu.com/questions/766334/cant-login-as-mysql-user-root-from-normal-user-account-in-ubuntu-16-04

이 문제의 주된 원인은 다음과 같습니다.auth_socketroot 사용자에게 패스워드가 없는 경우 현재 기본적으로 사용되는 플러그인입니다.(이전 apt-get 설치 프로세스에서는 root의 패스워드를 입력하도록 요구했지만 지금은 그렇게 하지 않는 것 같습니다.auth_socket이네이블이 됩니다.

두 쿼리 중 하나에 대해 먼저 다음을 사용하여 루트로 로그인합니다.sudo mysql

MySQL 또는 MariaDB > = 10.2의 경우:

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';

MariaDB < 10.2 (지원하지 않음)를 사용하는 다른 사용자용ALTER USER), 다음 쿼리를 실행합니다.

    SET PASSWORD = PASSWORD('test');
    update mysql.user set plugin = 'mysql_native_password' where User='root';
    FLUSH PRIVILEGES;

해결책은 루트 mysql 계정의 비밀번호를 제공하는 것입니다(아직 입력하지 않은 경우).에러 메세지가 표시되는 것은, 패스워드가 필요하지만, 패스워드를 지정하지 않았기 때문입니다.루트 비밀번호 재설정 방법:

$ mysqladmin -u root password
$ New password: 

또는 루트 패스워드를 이미 설정해 둔 경우(그렇지 않으면 sudo를 통해 로그인할 수 없을 것 같습니다.

$ mysqladmin -u root -p  password

mysql 사용자는 postgres와 달리 unix 사용자와 링크되지 않습니다.

서버 버전: 5.7.18-0ubuntu0.16.04.1 (우분투)

순서 1:

 server@Server:~$ sudo -i

순서 2:

 root@Server:~# mysql

출력은 다음과 같습니다.

 server@Server:~$ sudo -i
 [sudo] password for server: 
 root@Server:~# mysql
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 16
 Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

 Copyright (c) 2000, 2017, 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.

순서 3:

 mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Abc123123@';

출력:

 Query OK, 0 rows affected (0.00 sec)

다음 명령을 사용해 보십시오.

mysql -uroot -p[password]

[password] - mysql 설치 시 설정한 비밀번호를 입력합니다.

다음의 조작도 가능합니다.

sudo mysql -uroot -p[password]

언급URL : https://stackoverflow.com/questions/38098505/mysql-works-with-sudo-but-without-not-ubuntu-16-04-mysql-5-7-12-0ubuntu1-1

반응형