mysql--user表

时间:2022-08-11 10:29:13
mysql数据库 用例:mysql 
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
28 rows in set (0.01 sec)

mysql27张表中 user表保存登录mysql的用户信息

查看主键信息

SELECT
t.TABLE_NAME,
t.CONSTRAINT_TYPE,
c.COLUMN_NAME,
c.ORDINAL_POSITION
FROM
INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS t,
INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS c
WHERE
t.TABLE_NAME = c.TABLE_NAME
-- AND t.TABLE_SCHEMA = 数据库名称
AND t.CONSTRAINT_TYPE = 'PRIMARY KEY' and c.TABLE_NAME='user';

  mysql--user表

可是看到主键是user和host

查看数据

mysql--user表

建host设为%可使任意客户端进行连接

客户端远程连接不到数据库

可能原因:

1、服务器防护墙开着
2、user表问题 将user='' host=''
解决办法:
1、关闭防护墙
2、删除user='' and host=''记录