查看数据库:
show databases;
查看数据库信息:
show create database 数据库名;
查看表信息:
show create table 表名;
查看当前数据库版本号:
select version();
查看系统当前时间:
select new();
查看当前用户:
select user();
查看当前所在的数据库:
select database();
查看MySQL数据库状态:
status;
查看表的结构:
desc 表名;
查询数据库中所有的表名称:
show tables;
设置该用户从任意主机远程登录MySQL:
grant all privileges on *.* to userName@'%' identified by 'userPassword' with grant option;
远程登录:
mysql -h ip -u username -p password -P port
添加用户:
create user 'username'@'localhost' identified by 'password';
设置用户密码:
update user set password=password("yourPassword") where user="username";
当前登录用户修改密码:
set password=password("newPassword");