flagflag  If you want to see English page, please click "English" Button at Left.
1: 2009-04-20 (月) 23:26:02 iseki ソース
Line 1: Line 1:
 +*** mySQL 操作メモ(一般) [#db4d646a]
 +**** 他のホストへ接続 [#q7869186]
 + mysql -u netp_user -h 202.26.158.3 -p
 +**** テーブル参照権限を与える [#l20b404f]
 + grant references on netp_exam.* to netp_user identified by 'netp_pass';
 +
 +**** select 権限を与える [#l5fb8d31]
 + grant select on netp_exam.* to netp_user identified by 'netp_pass';
 +
 +- データベース一覧
 + show databases;
 +
 +- テーブル一覧
 + use データベース名;
 + show tables;
 +
 +- テーブル削除
 + use データベース名;
 + drop table テーブル名;
 +
 +- 項目削除
 + delete  from テーブル名 where 条件;
 + 例: delete  from mdl_log_display where module="quiz";
 +
 +** データベースのチェックとリペア [#u5850f80]
 +- データベースを止めてから,チェックを行う
 + # /etc/init.d/mysql stop
 + # /usr/local/mysql/bin/myisamchk /var/mysql/[DBNAME]/*.MYI
 + # /etc/init.d/mysql start
 +
 +** データベースの移行 MySQL4 -> MySQL5 [#xe55be4b]
 ++ MySQL5 を MySQL4と被らないようにインストールする.
 ++ MySQL5 のデータベースを作成する(初期化する).
 +  # /usr/local/mysql5/bin/mysql_install_db --user=mysql --ldata=/var/mysql5
 +  # cp support-files/my-medium.cnf /var/mysql5/my.cnf
 +  # chown mysql /var/mysql5/my.cnf
 +  # /etc/init.d/mysql5 を作る
 ++ MySQL4 の移行するデータベース(xoops)をダンプする.
 +  # /usr/local/mysql/bin/mysqldump -x xoops -u root -p > xoops.dump
 ++ MySQL4 を止めて,MySQL5 を起動する.
 + # /etc/init.d/mysql  stop
 + # /etc/init.d/mysql5 start
 + # /usr/local/mysql5/bin/mysqladmin -u root password パスワード
 ++ MySQL5 で受け入れ側となる個別のデータベースを作成し,権限を旧データベースと同様に設定する.
 + mysql> create database xoops;
 + mysql> grant all on xoops.* to xoops_user identified by 'xoops_pass';
 ++ データをリストアする.
 + mysql> source xoops.dump        xoops.dump は mysqlが読める必要がある.
 ++ または
 + # /usr/local/mysql5/bin/mysql xoops -u root -p < xoops.dump
 +
 +*** データベースの移行 [#hb5ad3ec]
 +- 移行元のデータベースの CHARSETが latin1 で EUCで保存
 +- 移行先は utf8
 + % mysqldump source_db source_table --default-character-set=latin1 -x -u root -p > table_data
 + % nkf -w table_data > table_data.utf8
 +table_data.utf8内のテーブル名,CHARSETを新しいデータベースに合わせる.
 + % mysql dist_db -u root -p < table_data.utf8
 +
 +** UTF-8 で使用する場合 [#sc952334]
 + mysql> show variables like "char%";
 + +--------------------------+-----------​------------------------------------+
 + | Variable_name            | Value                                        |
 + +--------------------------+-----------​------------------------------------+
 + | character_set_client    | latin1                                        |
 + | character_set_connection | latin1                                        |
 + | character_set_database  | latin1                                        |
 + | character_set_filesystem | binary                                        |
 + | character_set_results    | latin1                                        |
 + | character_set_server    | latin1                                        |
 + | character_set_system    | utf8                                          |
 + | character_sets_dir      | /usr/local/mysql-5.0.67/share/mysql/char​sets/ |
 + +--------------------------+-----------​------------------------------------+
 +この場合は latin1 を utf8にする
 + mysql> set character_set_client=utf8;
 + mysql> set character_set_connection=utf8;
 + mysql> set character_set_database=utf8;
 + mysql> set character_set_results=utf8;
 + mysql> set character_set_server=utf8;
 + mysql> show variables like "char%";
 + +--------------------------+-----------​------------------------------------+
 + | 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                                          |
 + | character_sets_dir      | /usr/local/mysql-5.0.67/share/mysql/char​sets/ |
 + +--------------------------+-----------​------------------------------------+


トップ   新規 ページ一覧 単語検索 最終更新   ヘルプ   最終更新のRSS 1.0 最終更新のRSS 2.0 最終更新のRSS Atom

サイト内 検索

ログイン

ユーザー名:

パスワード:


パスワード紛失
新規登録

サブ メニュー

ミニカレンダー

前月2024年 4月翌月
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
<今日>

オンライン状況

82 人のユーザが現在オンラインです。 (20 人のユーザが xpwiki を参照しています。)

登録ユーザ: 0
ゲスト: 82

もっと...

アクセスカウンタ

今日 : 1037710377103771037710377
昨日 : 2042920429204292042920429
総計 : 2338978323389783233897832338978323389783233897832338978323389783
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project
Design by XoopsDesign.com