MySql常用命令

一、mysql服务的启动和停止

   net stop mysql
   net start mysql

二、登陆mysql

   语法如下: mysql -u用户名 -p用户密码

   键入命令mysql -uroot -p, 回车后提示你输入密码,输入12345,然后回车即可进入到mysql中了,mysql的提示符是:

mysql>

注意,如果是连接到另外的机器上,则需要加入一个参数-h机器IP

三、增加新用户

   格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"

   如,增加一个用户user1密码为password1,让其可以在本机上登录, 并对所有数  据库有查询、插入、修改、删除的权限。首先用以root用户连入mysql,然后键入以下命令:

   grant select,insert,update,delete on *.* to user1@localhost Identified by "password1";

如果希望该用户能够在任何机器上登陆mysql,则将localhost改为"%"。

如果你不想user1有密码,可以再打一个命令将密码去掉。

grant select,insert,update,delete on mydb.* to user1@localhost identified by "";

四、其他常用命令

-- 获取当前用户
select user();

-- 获取当前用户的权限
show grants;

-- 获取当前用户的数据库 
show databases;

-- 获取当前用户的默认数据库的表 
show tables;


-- 获取指定数据库的所有表 
select table_name from information_schema.tables
where table_schema='WLLiuXue_MySql' and table_type='base table';

-- 获取指定表中的所有列 

select column_name from information_schema.columns
where table_schema='WLLiuXue_MySql' and table_name='Video';


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值