MySql常用简单命令

1、启动和停止MySql服务

net stop mysql

net start mysql

2、登录MySql

 mysql -u用户名 -p用户密码,例如mysql -uroot -p用root账号登录

3、添加用户及权限

grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码",例如grant select,insert,update,delete on *.* to user1@localhost Identified by "password1";

4、操作数据库

4.1、显示数据库列表。

show databases;

4.2、显示某一个数据库中的数据表

use 数据库名;

show tables;

4.3、显示数据表的结构:

describe 表名;

或desc 表名;

或show columns from 表名;

4.4、新建或删除数据库

create database 库名;

drop database 库名;

4.5、新建或删除数据表

create table 表名(字段列表);

drop table 表名;

例如;

create table MyClass(
 id int(4) not null primary key auto_increment,
name char(20) not null,
sex int(4) not null default '0',
degree double(16,2));

4.6、清空数据表

delete from 表名;

4.7、插入数据

insert into 表名 values(值1,值2,...);

或insert into 表名(列1,列2,...) values(值1,值2,...);

4.8、更新数据

update 表名 set 列名1=新值2,列名2=新值2,... where 条件;

4.9、查询数据

select 列名1,列名2 from 表名;

4.10、删除数据

delete from 表名 where 列名1=值1 and 列名2=值2;

5、退出

quit;

或exit;


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值