LoginSignup
0
0

More than 1 year has passed since last update.

備忘:MySQLでデータベースの中身を確認する方法

Posted at

よく忘れて、探すので備忘

本当にデータが登録されているかとかで使う

まずはターミナルからMySQLに接続する

ルートで接続

mysql -u root
本当は危険
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 276
Server version: 5.6.51 Homebrew

参考
https://www.dbonline.jp/mysql/connect/index3.html

データベースを選択する

use cooklog; 

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

使うデータベースがわからない場合は
databese.ymlで確認

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: cooklog_development
  pool: 5
  username: kiyomasa

  host: localhost

test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: cooklog_test
  pool: 5
  username: kiyomasa

  host: localhost

参考:https://www.dbonline.jp/mysql/database/index3.html

テーブルを確認

mysql> SELECT * FROM favorites;
+----+---------+-----------+----------------------------+----------------------------+
| id | user_id | recipe_id | created_at                 | updated_at                 |
+----+---------+-----------+----------------------------+----------------------------+
|  1 |       1 |        23 | 2021-07-26 23:38:18.303379 | 2021-07-26 23:38:18.303379 |
+----+---------+-----------+----------------------------+----------------------------+
1 row in set (0.00 sec)

mysql>  SELECT * FROM users;
+----+------------+-------------------+--------------------------------------------------------------+----------------------------+----------------------------+
| id | name       | email             | password_digest                                              | created_at                 | updated_at                 |
+----+------------+-------------------+--------------------------------------------------------------+----------------------------+----------------------------+
|  1 | sample1_18 | wanko1@prog-8.com | $2a$12$WbBJmW91Y4qDNBqy/h17A.XHpknRAD4NHtgXGO6YURP3U6IuKUMeS | 2021-05-09 04:45:52.315260 | 2021-07-25 04:43:25.422336 |
|  3 | aaaaa      | wanko5@prog-8.com | $2a$12$PBkaJE.sc5VI2Nl5UsBLle.rmUbmxkz0NDTSUXoaOcQ4MtKGc1ox. | 2021-06-21 22:02:01.573754 | 2021-06-21 22:02:01.573754 |
|  4 | aaaaa      | wanko6@prog-8.com | $2a$12$jKle2Pi5vIrNQ3tacVeo8ugTpy/IzR37Heyq3q76pvlmc3.joWl2G | 2021-06-23 22:18:20.534653 | 2021-06-23 22:18:20.534653 |
+----+------------+-------------------+--------------------------------------------------------------+----------------------------+----------------------------+
4 rows in set (0.01 sec)

参考:https://oreno-it3.info/archives/853

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0