0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

備忘録 SQL 始めるとき Colud9

Posted at

##SQLの勉強兼ねた備忘録です。

起動

$ sudo service mysqld start

再起動

$ sudo service mysqld restart

起動状態確認

$ sudo service mysqld status

停止

$ sudo service mysqld stop

データベースサーバへの接続

$ mysql -u root

データベースサーバからの切断

mysql> exit

文字化け対策の設定ファイルを作成

sed -e "/utf8/d" -e "/client/d" -e "/^[mysqld_safe]$/i character-set-server=utf8\n\n[client]\ndefault-character-set=utf8" /etc/my.cnf |sudo tee /etc/my.cnf

文字化け対策ができているかの確認

mysql> show variables like "chara%";

データベース作成

sql> CREATE DATABASE bookstore;

データベースを削除(注意して使う)

mysql> DROP DATABASE bookstore;

現在作成されている全てのデータベースの一覧を確認

mysql> show databases;

操作するデータベースを選択

mysql> USE bookstore;

テーブル一覧の確認

mysql> show tables;

テーブルの設計内容を確認

mysql> describe books;

テーブルを削除したい場合

mysql> DROP TABLE bookstore.books;

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?