mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed mysql> select host,user from user;; +-----------+------------------+ | host | user | +-----------+------------------+ | localhost | mysql.infoschema | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | //只有localhost本机才可以连接数据库 +-----------+------------------+ 4 rows in set (0.00 sec) mysql> update user set host = '%' where user = 'root';//任何主机都可以远程连接 Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host,user from user;; +-----------+------------------+ | host | user | +-----------+------------------+ | % | root | | localhost | mysql.infoschema | | localhost | mysql.session | | localhost | mysql.sys | +-----------+------------------+ 4 rows in set (0.00 sec) mysql> flush privileges;//更新 Query OK, 0 rows affected (0.01 sec) mysql> alter user 'root'@'%' identified with mysql_native_password by '196131'; Query OK, 0 rows affected (0.01 sec)