データ管理系コマンド
- テーブルの情報を見る
describe テーブル名;
データベース管理系コマンド
ユーザー追加
grant alter,create,delete,insert,select,update on <databasename>.<tablename> to username@hostname identified by 'password';
ユーザー追加を有効にする
flush privileges;
パスワード変更
set password for root@localhost=password('rootpassword');
データベースの整合性チェック
mysqlcheck DATABASE_NAME
バックアップ
mysqldump -u user -ppassword -x --all-databases > backupfile
リストア
mysqldump -u user -ppassword < backupfile mysql -u user -ppassword < backupfile
テーブル作成 (例)
create table ( userID int unsigned not null default 0, userName varchar(255) not null default '', date datetime, primary key (userID) );
TIPS
以下のようなエラーが発生するときは
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'
以下のコマンドを実行する
cat /etc/mysql/debian.cnf | grep password mysql -u root -p GRANT ALL PRIVILEGES on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES;
以下のメッセージは特に問題ないらしい
/etc/init.d/mysql restart Stopping MySQL database server: mysqld. Starting MySQL database server: mysqld. Checking for corrupt, not cleanly closed and upgrade needing tables..
