MySQL 操作Tips

文字コードの確認

キャラセット関連のシステム変数を確認するには、mysqlクライアントコマンドを起動し、キャラセットの環境変数を表示させる。

$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.26

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

キャラセットの環境変数は下記に表示させる

SHOW VARIABLES LIKE 'character\_set\_%';

下記の様な表示結果となる

mysql> SHOW VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | utf8   | 
| character_set_connection | utf8   | 
| character_set_database   | utf8   | 
| character_set_filesystem | binary | 
| character_set_results    | utf8   | 
| character_set_server     | utf8   | 
| character_set_system     | utf8   | 
+--------------------------+--------+
7 rows in set (0.01 sec)

rootユーザにフルアクセス権限を付与する

mysql -uroot -e "GRANT all privileges ON *.* TO root with grant option;"

ダンプファイルのリストア

mysql -u[USER] -p[PASSWORD] [DATABASE] < ダンプしたファイル 

データベースの作成

create database [DATABASE];
\q

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS