at /home/scar/code/forum/vendor/laravel/framework/src/Illuminate/Database/Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {
> 665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|
Exception trace:
1 PDOException::("SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'")
/home/scar/code/forum/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=forum", "root", "", [])
/home/scar/code/forum/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Please use the argument -v to see more details.
scar@scar-W65-67SF:~/code/forum$ sudo mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.17-0ubuntu2 (Ubuntu)
Copyright (c) 2000, 2019, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set plugin='' where User='root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> \q
Bye
ubuntu같은 일부 리눅스 시스템에서 mysql을 설치하고
$ mysql -u root -p 으로 로그인 시도를하면
'ERROR 1698 (28000): Access denied for user 'root'@'localhost'이라는 에러를 발생할때가 있다.
이는 기본적으로 초기설정되어있는 mysql의 root 계정의 패스워드 타입때문인데
이 타입을 변경해주면된다.
아래처럼 확인해본다.
-----
$ sudo mysql -u root # sudo를 사용하여 root계정으로 mysql에 접속한다.
mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;
+------------------+-----------------------+
| User | plugin |
+------------------+-----------------------+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
위처럼 root의 plugin이 auth_socket으로 설정되어있는것을 확인할 수 있다.
이 값을 mysql_native_password로 변경해주면 일반적인 로그인이 가능하다.
mysql> update user set plugin='mysql_native_password' where user='root';
mysql> flush privileges;
mysql> select user, host, plugin from user;
+------------------+-----------------------+
| User | plugin |
+------------------+-----------------------+
| root | mysql_native_password || mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
mysql> exit;
출처 :https://bscnote.tistory.com/77
댓글 없음:
댓글 쓰기