%3A%20'root'%40'localhost'%20%EC%82%AC%EC%9A%A9%EC%9E%90%EC%97%90%20%EB%8C%80%ED%95%9C%20%EC%95%A1%EC%84%B8%EC%8A%A4%EA%B0%80%20%EA%B1%B0%EB%B6%80%EB%90%98%EC%97%88%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
alhelal@VimLaTeX:~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
alhelal@VimLaTeX:~$ sudo mysql -u root -p
[sudo] password for alhelal:
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 10.1.29-MariaDB-6 Ubuntu 18.04
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
mariadb가 일반 우분투 사용자가 mysql 루트 사용자로 mysql을 입력하는 것을 허용하지 않는 이유는 무엇입니까?
나도 시도했다오류 1698(28000): Ubuntu 18.04에서 'root'@'localhost' 사용자에 대한 액세스가 거부되었습니다.그런데 실패했어?
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test'' at line 1
답변1
에 따르면이 답변auth_socket
SO에서는 루트 사용자가 Ubuntu의 MySQL/MariaDB에서 기본적으로 사용되는 플러그인을 사용하고 있기 때문일 수 있습니다 .
$ sudo mysql -u root
MariaDB [mysql]> USE mysql;
MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+------------------+-----------------------+
| User | plugin |
+------------------+-----------------------+
| root | auth_socket |
+------------------+-----------------------+
이를 다음으로 변경하면 다음을 mysql_native_password
요구하지 않고도 연결할 수 있습니다 sudo
.
$ sudo mysql -u root
MariaDB [mysql]> USE mysql;
MariaDB [mysql]> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> exit;
$ service mysql restart