更改mysql配置文件

查找.ini或者.cnf文件
在这里插入图片描述

  • 更改bind-address0.0.0.0
[mysqld]
character-set-server=utf8mb4
bind-address=0.0.0.0
default-storage-engine=INNODB
[mysql]
default-character-set=utf8mb4
[client]
default-character-set=utf8mb4
登录mysql
mysql -u root -p

输入密码

E:\mysql-8.0.22-winx64\bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  • 使用mysql
use mysql;
mysql> use mysql;
Database changed
  • 查看目前mysql的用户和host
select user,host from user;
mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| username         | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
5 rows in set (0.03 sec)

在这里插入图片描述

  • 更改root用户的host为全部
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐