1.mysql(客戶端鏈接工具):
-u :指定用戶名
-p:指定密碼
-h:指定服務器ip或者域名
-P(大寫):指定端口
例子:mysql -u root -h 202.194.132.237 -P 3306 -p
出現error: Host '202.194.132.237' is not allowed to connect to this MySQL server
出現上述原因是因為:該用戶沒有權利進行遠程訪問,必須登陸數據庫修改用戶的權限.
設置用戶管理權限:
grant 權限列表 [(字段列表)] on 數據庫名.表名 to 用戶名@域名或ip地址 [identified by '密碼'] [with grant option]
eg:
1. grant all on *.* to wuxiaoxiao@'%' identified by '870805'
2. grant select on java.* to wuxiaoxiao@'202.194.132.%' identified by '870805';
grant update (name) on java.customer to wuxiaoxiao@'%';
3. grant all on *.* to wuxiaoxiao@'localhost' identified by '870805';
revoke 權限列表[(字段列表)] on 數據庫.表名 from 用戶名@域名或ip地址
eg:revoke create,drop on java.* from wuxiaoxiao@'%';
revoke grant option on java.* from wuxiaoxiao@localhost;
登陸系統后:select current_user();查看當前鏈接的用戶
--default-character-set=gbk:設置客戶端字符集選項
eg:mysql -u root --defaule-character-set=gbk -p登陸后:
等價與set names gbk;
show variables like 'chara%';查看客戶端字符集
-e:執行sql語句並退出:
msyql -u root -e "select * from user" 數據褲名字 -p
-E:將輸出方式按照字段順序豎着顯示
-s:去掉mysql中的線條框顯示
eg:mysql -u root -e "select * from user" BBS -p -E
-f:強行執行sql語句
-v:顯示更多信息
--show-warnings:顯示警告信息
eg:
在數據庫test中有個表t2,只有一個字段id,是int型的
有以下幾條插入語句(a.sql):
insert into t2 values(1);
insert into t2 values(2a);//錯誤
insert into t2 values(3);
不加上任何參數:
mysql -u root test(database-name) < a.sql
會出現錯誤,一條sql都沒有執行
加上參數-f:
mysql -u root test(database-name) -f< a.sql
只有錯誤的那行沒有執行
加上-v顯示插入的詳細信息:
mysql -u root test(database-name) -f -v< a.sql
加上--show-warnings
mysql -u root test(database-name) -f -v --show-warnings< a.sql
2.myisampack(MyISAM表壓縮工具)
eg:myisampack t3(t3.myd)
3.mysqladmin(MySQL管理工具)
mysqladmin和mysql客戶端登陸后執行的一些功能非常類似!
可以執行的命令:
