mysql數(shù)據(jù)庫常用命令
1.開啟和關(guān)閉
net stop mysql #停止mysql
net start mysql #開啟mysql
2.創(chuàng)建表,如:
create table myclass
3.刪除
drop table myclass; #刪除表
delete from myclass; #清空表
drop myclass #刪除表
4.導(dǎo)入導(dǎo)出數(shù)據(jù)庫
導(dǎo)出數(shù)據(jù):
mysqldump --opt test > d:db_name.sql #備份數(shù)據(jù)庫
mysql -udb_user -pdb_password db_name < d:db_name.sql #還原數(shù)據(jù)庫
5.修復(fù)表
repair table table_name; #修復(fù)表
6.進入mysql服務(wù)
mysql -uuser -ppassword
7.相關(guān)的基本查詢
show databases; #查看所有數(shù)據(jù)庫
use db_name; #選擇某個數(shù)據(jù)庫
show talbes; #查看選擇后的某數(shù)據(jù)庫所有表
8.創(chuàng)建用戶名create user name;
給用戶賦登錄密碼update mysql.user set password=password('password1') where user="name"; 也可以在root用戶下用此命令修改其他數(shù)據(jù)庫密碼。
給用戶授予所有的權(quán)限grant all privileges on *.* to name@"%" Identified by "password1" with grant option;
