一、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';



本文转载:CSDN博客