1. 修改root密码
mysqladmin -u root -p 原来密码 password 修改为的密码
2. 查看运行状态
show status;
show variables;
show processlist;
3. 用户权限管理
grant 权限 on 数据库对象 to 用户
grant 权限 on 数据库对象 to 用户 identified by "密码"
//开放管理MySQL中所有数据库的权限
grant all on *.* to dba1@'192.168.0.10'identified by "dbapasswd";
//开放管理MySQL中具体数据库(testdb)的权限
grant all privileges on testdb to dba1@'192.168.0.10'identified by "dbapasswd";
或
grant all on testdb to dba1@'192.168.0.10'identified by "dbapasswd";
//开放管理MySQL中具体数据库的表(testdb.table1)的权限
grant all on testdb.teable1 to dba1@'192.168.0.10'identified by "dbapasswd";
//开放管理MySQL中具体数据库的表(testdb.table1)的部分列的权限
grant select(id, se, rank) on testdb.table1 to ba1@'192.168.0.10'identified by "dbapasswd";
//开放管理操作指令
grant select, insert, update, delete on testdb.* to dba1@'192.168.0.10'identified by "dbapasswd";
//回收权限
revoke all on *.* from dba1@localhost;
//查看 MySQL 用户权限
show grants;
show grants for dba1@localhost;
MySQL grant、revoke 用户权限注意事项
1. grant, revoke 用户权限后,该用户只有重新连接 MySQL 数据库,权限才能生效。
2. 如果想让授权的用户,也可以将这些权限 grant 给其他用户,需要选项 “grant option“
grant select on testdb.* to dba@localhost with grant option;
5.数据库编码查看
show variables like 'char%';
6.查看SQL语句的解释
explain select * from cdb_forums;
7.查看系统执行的SQL语句
A、日志方式
首先你需要创建一个日志文件log.txt
,然后只需要在
mysql的配置文件 my.ini
中最后添加
log=d:/mysql/data/log.txt
这样可以记录所有的mysql执行的sql语句!
B、命令方式
show processlist