常用命令
登錄數據庫
mysql -h localhost -uroot -p
導出數據庫
mysqldump -uroot -p db > db.sql
導入數據庫
mysql -uroot -p db < db.sql
// or
mysql -uroot -p db -e "source /path/to/db.sql"
開啟遠程登錄
grant all privileges on ss.* to 'root'@'%' indentified by 'passoword' with grant option;
// or
update user set Host="%" and User="root"
// 注意%是不包含localhost的
flush privileges;
創建用戶
CREATE USER 'test'@'localhost' IDENTIFIED BY 'password';
grant all privileges on *.* to test@'localhost' identified by 'test';
創建表
CREATE SCHEMA testdb DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
賦予數據庫權限
GRANT ALL ON testdb.* TO 'test'@'localhost';