Markdown

[MySQL] Access denied for user

```
[root@localhost ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
```

http://mustgeorge.blogspot.tw/2011/11/mysql-error-1045-28000-using-password.html
https://dev.mysql.com/doc/refman/5.7/en/adding-users.html

# creat user

先使用root登入
```
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.18 MySQL Community Server (GPL)

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.

mysql> CREATE USER 'eric_tu'@'localhost' IDENTIFIED BY 'Eric_tu168';
Query OK, 0 rows affected (0.02 sec)

```

```
mysql> GRANT ALL PRIVILEGES ON *.* TO 'eric_tu'@'localhost';
Query OK, 0 rows affected (0.01 sec)

```

切回 eric_tu@

```
[eric_tu@localhost DoctrineToutorial]$ mysql -u eric_tu -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.18 MySQL Community Server (GPL)

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.

mysql>
```

留言