MySQLにテスト用のデータベースを作る。 | tabi0のブログ

tabi0のブログ

(^^)/

MySQL Command Line Clientを起動
パスワード入力

データベース作成
create database test;

データベース一覧
show database;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+

データベース選択
use test:

テーブル作成
create table t1(
 no int primary key,
 name char(12)
);


テーブル一覧
show tables;


mysql> SHOW COLUMNS from t1;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| no    | int(11)  | NO   | PRI | NULL    |       |
| name  | char(12) | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+


ユーザーとパスワード設定。
grant select,insert,update,delete on t1 to 'testuser'@'localhost' identified by 'testpass';