2017-02-14

MySQLでユーザーに設定したパスワードが効かなくて嵌った件

Amazon Linuxでyumを使ってMySQL56をインストールし起動し、データベースとユーザーを作成して
ログインしてみると設定したパスワードでログインできないではありませんか(;゜〇゜)

  1. mysql> create database mydb character set utf8;  
  2. mysql> grant all on mydb.* to user identified by 'xxxxx';  
  3.   
  4. $ mysql -u user -p  
  5. Enter password:   
  6. ERROR 1045 (28000): Access denied for user 'user '@'localhost' (using password: YES)  

ところが、パスワードなしでログインを試みるとは入れてしまいましたΣ(゜д゜;)

プロセスを確認してみると指定したユーザーでログインしています。

  1. $ mysql -u user  
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  3. Your MySQL connection id is 30  
  4. Server version: 5.6.35 MySQL Community Server (GPL)  
  5.   
  6. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.  
  7.   
  8. Oracle is a registered trademark of Oracle Corporation and/or its  
  9. affiliates. Other names may be trademarks of their respective  
  10. owners.  
  11.   
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  13.   
  14. mysql> show processlist;  
  15. +----+-----------+-----------+------+---------+------+-------+------------------+  
  16. | Id | User  | Host      | db   | Command | Time | State | Info  |  
  17. +----+-----------+-----------+------+---------+------+-------+------------------+  
  18. | 28 | user      | localhost | NULL | Query   |    0 | init  | show processlist |  
  19. +----+-----------+-----------+------+---------+------+-------+------------------+  
  20. 1 row in set (0.00 sec)  

ユーザーテーブルどーなってるか確認してみるとユーザー名なし、パスワードなしの登録が入っていました

あやしいです(;一_一)

  1. mysql> select user,host from user;  
  2. +-----------+------------------+-------------------------------------------+  
  3. | user     | host        | password       |  
  4. +-----------+------------------+-------------------------------------------+  
  5. | user      | %         | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |  
  6. | root     | 127.0.0.1        |                                           |  
  7. | root     | ::1        |                                           |  
  8. |     | ip-xxx-xx-xx-xxx |                                           |  
  9. | root     | ip-xxx-xx-xx-xxx |                                           |  
  10. |     | localhost        |                                           |  
  11. | root     | localhost        |                                           |  
  12. +-----------+------------------+-------------------------------------------+  
  13.   
  14. mysql> select host from user where user="";  
  15. +------------------+  
  16. | host     |  
  17. +------------------+  
  18. | ip-xxx-xx-xx-xxx |  
  19. | localhost    |  
  20. +------------------+  
  21. 2 rows in set (0.00 sec)  

怪しいので消してしまいましょうヽ(´ー`)/
  1. mysql> delete from user where user="";  
  2. Query OK, 2 rows affected (0.00 sec)  
  3.   
  4. mysql> FLUSH PRIVILEGES;  
  5. Query OK, 0 rows affected (0.00 sec)  

そしたら、次の通り入れました!ヾ(*・∀・)ノ"
  1. $ mysql -u user -p  
  2. Enter password:   
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  4. Your MySQL connection id is 30  
  5. Server version: 5.6.35 MySQL Community Server (GPL)  
  6.   
  7. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.  
  8.   
  9. Oracle is a registered trademark of Oracle Corporation and/or its  
  10. affiliates. Other names may be trademarks of their respective  
  11. owners.  
  12.   
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  14.   
  15. mysql>   

1 件のコメント:

  1. TINING TECHNOLOGY AND MATERIAL: TINING TECHNOLOGY & MATERIAL
    TINING TECHNOLOGY AND MATERIAL: titanium astroneer TINING TECHNOLOGY AND MATERIAL: columbia titanium TINING titanium mens rings TECHNOLOGY & MATERIAL: titanium trim reviews TINING TECHNOLOGY babyliss pro titanium & MATERIAL: TINING TECHNOLOGY & MATERIAL: TINING TECHNOLOGY

    返信削除