全文検索:
- MySQLコマンド
- ンド ====== ===== ①ユーザ関係 ===== ==== ユーザの確認 ==== <code console> mysql> select host,user,password,Grant_p... -------+------------+ 12 rows in set (0.00 sec) </code> ==== 権限の確認 ==== <code console> mysql> SHOW GRANTS FOR testdb_user@localhost; +---------------------... ----------------------------------------------+ </code> === 権限の追加 === <code> グローバルレベル GRANT ALL ON *.*
- 15 MySQL 55 to 56 で問題
- ative_passwordで、passwordが41桁のハッシュ値になっている必要があります。 <code> mysql> select host,user,password,Grant_priv,plug... ---------------------+ 5 rows in set (0.00 sec) </code> ===== 古いパスワードのままログインする場合 ===== Server側とClient側... ltが設定されてないカラムにNULLを入れようとした時に出る。 ==== 対応方法 ==== <code> mysql> SHOW GLOBAL VARIABLES like 'sql_mode'; +-... ---------------------+ 1 row in set (0.00 sec) </code> === /etc/my.cnf === 再起動後も設定反映させるために、my.cnfも修正
- MySQL - ログローテート
- tc/newsyslog.confに記述。 今回は一週間分、圧縮せずにローテートするよう記述。 <code> # vi /etc/newsyslog.conf -----------------追加--... 00 B -----------------追加-------------------- </code> /etc/crontabにパーミッション変更とMySQLのflush-logsを実行。 <code> # vi /etc/crontab 01 0 * * * root /usr/sbin/chow... sqladmin -u root -p[MySQLのrootパスワード] flush-logs </code> <color red>※root -p[MySQLのrootパスワード]の個所は-pの後にスペ
- 18 MySQLでALTER TABLEの進捗確認
- なので、ALTER TABLEをかけたテーブルの件数が分かればだいたいの終了時間が想定できる。 <code | alert_progress.sh> #!/bin/bash while true do ... $2}'` echo `expr $CUR - $PRE` sleep 1 done </code> ===== 例 ===== 下記の例だと、テーブルに12万行あって 1秒間に、200000行処理しているので、およそ106分くらいで終わるという計算になる。 <code> mysql> select count(id) from test_table; +------... in set (10 min 26.05 sec) $ bash alert_progress.sh 200000 200000 200000 ・ ・ ・ </code> {{tag>mysql}}
- 17 MySQL view一覧
- ====== 17 MySQL view一覧 ====== <code> SELECT table_name, table_schema FROM information_schema.tables WHERE table_type = 'VIEW'; </code> {{tag>mysql}}
- 01 MySQL インデックス
- index_name(name, created); ==== テーブル作成時 ==== <code> mysql> create table cloudstack_domain_resource... ey index_date(created_at), key index_domain(domain,created_at) ) ENGINE=InnoDB; </code> {{tag>mysql}}
- MySQL - クエリ全部ログ取得
- 確認 ===== この場合ログファイルは、/var/run/mysqld/mysqld.log <code> mysql> show global variables like 'general_log_f... (0.00 sec) mysql> set global general_log='OFF'; </code> ===== ログを取得開始 ===== <code> mysql> set global general_log='ON'; </code> ===== ログを取得停止 ===== <code> mysql> set global general_log=
- MySQL - シェルで枠まで出力する
- ===== MySQL - シェルで枠まで出力する ====== 下記のようなテーブルがある <code console> # mysql -u root testdb -e 'select * from... 5 | E | | 6 | F | +------+------+ </code> リダイレクトしたり、パイプでつなげたりすると枠は消えてしまいます。 <code console> # mysql -u root testdb -e 'select * from table1' > ... # cat /tmp/aaa id name 1 A 2 B 3 C 4 D 5 E 6 F </code> たまにこの枠も欲しい場合がある。 「--table」を付けると枠も一緒に出力してくれます。
- 20 wait_timeoutとthread_cache_size
- ut ===== デフォルトでは、MySQL側でconnectionを8時間保持し続けます。 <code console> mysql> show global variables like 'wait_... -------------+-------+ 1 row in set (0.00 sec) </code> <code |my.cnf> wait_timeout = 360 </code> ===== thread_cache_size ===== wait_timeout を減らすと、その分スレッドをthreadを生
- MySQL - slow log
- ry_timeで指定)なのでそのクエリを見直す。 これで動いてるプロセスを見ることもできる。 <code console> mysql > show full processlist; mysql> SHOW PROCESSLIST; mysql> SHOW FULL PROCESSLIST; </code> 以下がイコールなので、下だとwhereが使える <code console> mysql> SELECT * FROM information_schema.PROCESSLIST where COMMAND='Query'; </code> ====== オンラインで変更 ====== ===== 5.0 ===== <code>
- MySQL - Transaction
- OMMIT(DBに結果を反映)かROLLBACK(トランザクション開始前の状態に戻す)をする。 <Code sql> mysql> START TRANSACTION; </Code> START TRANSACTION以降のクエリをDBに反映させてトランザクションを完了する場合は以下のようにする。 my
- 81 ERROR 1267 (HY000): Illegal mix of collations
- して、utf8_unicode_ciのクエリを送ったり ===== エラー内容 ===== <code> ERROR 1267 (HY000): Illegal mix of collations (u... nd (utf8_unicode_ci,IMPLICIT) for operation '=' </code> ==== 対処 ==== 下記の照会順序変更で修正を行う [[02_freebsd:04_d
- 11 ERROR:1093を回避
- 3を回避 ====== update の時同じテーブルに対するサブクエリからの操作ができない <code console> update hoge set code = 0 where id IN (select id from hoge as tmp where id = 1 group by id or... y target table 'hoge' for update in FROM clause </code> ===== 対応 ===== これで上手くいく <code console> update hoge set code = 0 where id IN ( select id from (sele
- LEFT JOIN、INNER JOIN違い
- NNER JOIN違い ====== ===== 下記2つのテーブルでテスト ===== <code console> mysql> SELECT * FROM table1; +------+---... | +------+------+ 6 rows in set (0.00 sec) </code> <code console> mysql> SELECT * FROM table2; +------+------+ | id | name | +------+------+ | 1 |... | +------+------+ 6 rows in set (0.00 sec) </code> ===== LEFT JOIN ===== <code console> mysql> s
- mysqldumpでエラー
- ====== mysqldumpでエラー ====== <code console> # mysqldump --skip-lock-tables -u hogehoge --password="hogeh... .10.10 for table 'account_netstats_view' (1142) </code> SHOW VIEW権限を付けてあげると、mysqldumpできました。 <code console> mysql> GRANT SELECT, SHOW VIEW ON *.* TO 'hogehoge'@'%'; </code>