1. 查看連接埠
Netstat –an
2. 登陸mysql伺服器
Mysql –u root –p mysql–hlocahost –u root –p
3. 選擇資料庫
Show databases
4. 設定字元集
set names 'gbk';
5. 查詢資料庫中的表
show tables;
6. 設定字元集
set names'gbk';
7.
建立表
create tabletest(
tid int(10) not null,
tname varchar(100) notnull,
tdate datetime not null default'0000-00-00',
primary key(tid));
8. 查看錶結構
desc test;
9. 增加列
alter table testadd(tage int(3));
10. 修改列的預設值
alter table test altertag set default '0';
11. 刪除預設值
alter table test altertag drop default;
12. 刪除列
alter table test dropcolumn tag;
13. 插入資料
insert intotest(tid,tname,tdate) value(1,'ymm','2012-11-04');
14. 刪除表
drop table test;
15. 修改表名
alter tabletest rename test1;
16. 顯示資料庫版本
select version();
17. 重新整理資料庫
flush privileges;
18. 查詢目前時間
select current_date;
19. 將查詢出的資料寫入檔案
select * from test1into outfile "F:/test.txt" fields terminated by ",";
20. 查看資料庫狀態
status;
21. MySQL基本操作查看所有編碼
show variables like'character_set_%';
22. 主鍵設定自子增長
tid int(10) not null
auto_increment,//設定主鍵的時候
alter table auto auto_increment=(10);