MySQLのコマンドまとめ

忘れがちなMySQL関連のコマンド書式を都度更新で書いていく。というわけでいつでも工事中

データベースの削除

mysql> drop database データベース名;
Query OK, 11 rows affected (0.26 sec)

テーブルの削除

mysql> drop table テーブル名; 
Query OK, 0 rows affected (0.02 sec)

データベースの名前変更(ダンプして挿入)

# mysqladmin create newdatabase
# mysqldump olddatabase > olddatabase.sql
# mysql -u root newdatabase < olddatabase.sql

テーブルとカラム名の読み込みメッセージ

mysql> use wordpress
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

メッセージが出ても問題ないので気にしない。Tabキーで名称補完ができる状態。「-A」は「--no-auto-rehash」と同じ意味。「mysql -A -u ??? -p 」などとmysqlコマンドを起動する必要はない。

 

Checkingのワーニング対処

# /etc/init.d/mysql restart
[ ok ] Stopping MySQL database server: mysqld.
[ ok ] Starting MySQL database server: mysqld ..
[info] Checking for tables which need an upgrade, are corrupt or were not closed cleanly..

 解答:気にしない⇒https://setting-tool.net/mysql-debian-init.d