Loading

MySQL系列(二)日常管理命令

1.1授权root用户可以远程连接

mysql> use mysql;
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
mysql> flush privileges;

1.2查看数据库

mysql> show databases;

命令行查看数据库

[root@db01 ~]# mysql -uroot -p123456 -h 10.0.0.12 -e 'show databases;'

1.3查看编码

mysql> show variables like 'character%';

1.4选择数据库

mysql> use mysql;

1.5查看表

mysql> show tables;

1.5查看当前用户

mysql> select user();

 1.6查看所有用户,主机,密码

mysql> select user,host from mysql.user;mysql> select user,host,password from mysql.user;

 1.7查看所有用户的权限,查看单个用户的权限

mysql>  SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
mysql>  show grants for 'hola'@'localhost';  

 

 

posted @ 2017-11-12 19:40  宋某人  阅读(39)  评论(0编辑  收藏  举报