文章目录
- 更改mysql配置文件
- 登录mysql
更改mysql配置文件
查找.ini
或者.cnf文件
- 更改
bind-address
为0.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