LoginSignup
2

More than 5 years have passed since last update.

MySQLメモ:ドットインストールの復習

Last updated at Posted at 2013-11-29
ドットインストール:http://dotinstall.com/lessons/basic_mysql_v2

起動

mysql -u root -pパスワードがある場合

パスワード設定

set password for root@localhost=password('設定したいパスワード');

rootはいいが、@localhostを付ける意味がよく分からない・・・
ターミナル画面で出る[root@localhost]と関連性があるのだろうか?

データベース作成

create database データベース名;

rootユーザーにしか作れない?

確認

show databases;

データベースに移動

use データベース名;

削除

drop database データベース名;

ユーザーの追加

grant all on データベース名.* to ユーザー名@localhost identified by '設定したいパスワード';

テーブルの作成

create table users (
  フィールド名 型,
  intdata int,
  vchdata varchar(数値),
  chdata char(数値)
);

varcharとcharの違いが謎だったのでググりました。

参考:http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1113850201

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
2