jihyunjeongme / python-restapi-minitwitter

sign up coding
0 stars 0 forks source link

Mysql(DB) access Access denied for user 'root'@'localhost' #2

Closed jihyunjeongme closed 5 years ago

jihyunjeongme commented 5 years ago

sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) (Background on this error at: http://sqlalche.me/e/f405)

에러가 나는 경우 아래와 같이 대처

jihyun@jihyunjeongui-MacBook-Pro:~% mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.15 Homebrew

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> select user, plugin, host from mysql.user;
+------------------+-----------------------+-----------+
| user             | plugin                | host      |
+------------------+-----------------------+-----------+
| mysql.infoschema | caching_sha2_password | localhost |
| mysql.session    | caching_sha2_password | localhost |
| mysql.sys        | caching_sha2_password | localhost |
| root             | mysql_native_password | localhost |
+------------------+-----------------------+-----------+
4 rows in set (0.00 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'gosdkdI12#';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> select user, authentication_string,plugin,host from mysql.user;
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
| user             | authentication_string                                                  | plugin                | host      |
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
| mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| root             | *3CB41E45B0DFC7C3F324D5B1FC5AA3EEB0B58952                              | mysql_native_password | localhost |
+------------------+------------------------------------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)

mysql> exit
Bye

~ 2m 26s
jihyun@jihyunjeongui-MacBook-Pro:~% http -v POST "http://localhost:5000/sign-up" \
name=정지현  \
email=stophyuni@gmail.com  \
password=gosdk123  \
profile="Data Scientis"
POST /sign-up HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 114
Content-Type: application/json
Host: localhost:5000
User-Agent: HTTPie/1.0.2

{
    "email": "stophyuni@gmail.com",
    "name": "정지현",
    "password": "password",
    "profile": "Data Scientis"
}

HTTP/1.0 200 OK
Content-Length: 113
Content-Type: application/json
Date: Thu, 11 Apr 2019 23:53:05 GMT
Server: Werkzeug/0.14.1 Python/3.7.1

{
    "email": "stophyuni@gmail.com",
    "id": 1,
    "name": "정지현",
    "profile": "Data Scientis"
}

Database changed
mysql> select * from user;
ERROR 1146 (42S02): Table 'miniter.user' doesn't exist
mysql> show tables;
+-------------------+
| Tables_in_miniter |
+-------------------+
| tweets            |
| users             |
| users_follow_list |
+-------------------+
3 rows in set (0.00 sec)

mysql> select * from users;
+----+-----------+---------------------+-----------------+---------------+---------------------+------------+
| id | name      | email               | hashed_password | profile       | created_at          | updated_at |
+----+-----------+---------------------+-----------------+---------------+---------------------+------------+
|  1 | 정지현    | stophyuni@gmail.com | password        | Data Scientis | 2019-04-12 08:53:05 | NULL       |
+----+-----------+---------------------+-----------------+---------------+---------------------+------------+
1 row in set (0.00 sec)