LoginSignup
0
2

More than 3 years have passed since last update.

【初心者向け】MySQLでローカルにDBを作成する方法

Last updated at Posted at 2020-10-17

MySQLを勉強するためにローカルでDBを作成する方法を調べたので、備忘録的まとめ。
※MySQLが使える状態であることが前提。

1.MySQLを起動

$ mysql.server start
Starting MySQL
 SUCCESS! 

2.rootユーザーでログイン

2020-10-17T13:43:42.6NZ mysqld_safe A mysqld process already exists
mysql -u root // これを入力する
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.31 Homebrew

Copyright (c) 2000, 2020, 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>

3.DBを作成

mysql> create database testDB; // これを入力する
Query OK, 1 row affected (0.01 sec)

4.DBを確認

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| testDB             | // 作成したDBが入っている
+--------------------+
7 rows in set (0.00 sec)

5.DBを選択する

mysql> use testDB; // これを入力する
Database changed

6.テーブルを確認

mysql> show tables; // これを入力する
Empty set (0.00 sec)

→DBを作成しただけで、中身は空の状態

ここまでで、DBの作成は完了。

※DB作成後にデータを突っ込みたい方はこちらを参照
【MySQL】テーブルを作成して、CSVファイルからデータをインポートする方法

0
2
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
2