mysql 基本操作命令

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);

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值