1. 登录数据库
CMDàmysql -h 127.0.0.1 –u sa –p(回车后输入密码)
Enter password:****(回车)
2. 显示数据库
Mysql> show databases;
3. 打开或使用、切换数据库
Mysql> use mysql;
4. 删除数据库
Mysql>drop database testdb;
5. 显示数据库表
Mysql>show tables;
6. 建表语句
CREATE TABLE `faxrecv` ( `id` int(11) NOT NULL auto_increment, `RECV_TIME` varchar(20) default NULL, `CALLERID` varchar(20) default NULL, `CALLMYID` varchar(30) default NULL, `EXTENSION` varchar(32) default NULL, `RECV_ACCOUNT` varchar(64) default NULL, `TOTAL_PAGE` int(11) default NULL, `CHANNEL` int(11) default NULL, `FAXKEY` varchar(64) NOT NULL, `FILEFOLDER` varchar(255) default NULL, `FILETITLE` varchar(255) default NULL, `FILETYPE` varchar(20) default NULL, `STATUS` int(11) default NULL, PRIMARY KEY (`id`) ); |
7. 移除主键
Alter table faxstat drop primary key; |
8. 添加列并设为自增长主键
alter table faxstat add id int not null primary key auto_increment ; |
9. 导出、备份数据库
mysqldump -u sa -peastfaxresultext>d:\DB\201312181649_eastfaxresultext_backup.sql
10. 导入数据库
Mysql>use eastfaxresultextbackup; Mysql>source d:\DB\201312181613_eastfaxresultext_backup.sql 或Mysql>\. d:\DB\201312181613_eastfaxresultext_backup.sql |