1.忘记了MySQL的安装目录
进入mysql命令行输入:show variables like "%char%";
结果如下:
mysql> show variables like "%char%";
+--------------------------+---------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | D:\Program Files\MySQL\MySQL Server 8.0\share\charsets\ |
+--------------------------+---------------------------------------------------------+
8 rows in set, 1 warning (0.00 sec)
mysql>
需改变访问权限
处理方案:
1、该表法:
操作如下:
1.1 选择要使用的数据库
mysql> use mysql
1.2 查询
mysql> select host,user from user where user = 'root';
1.3 将localhost改成%,或改成固定的ip
mysql> update user set host='%' where user = 'root';
1.4 查询
mysql> select host,user from user where user = 'root';
1.5 刷新修改权限,使其生效
mysql> flush privileges;
2、授权法:
操作如下:
2.1 选择要使用的数据库
mysql> use mysql
2.2 更改远程连接设置,'myuser'为用户名,'mypassword'为密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
2.3 刷新修改权限,使其生效
mysql> flush privileges;
3.Windows下使用dos命令进入mysql
(注意:需配置环境变量)
C:\WINDOWS\system32>net start mysql
请求的服务已经启动。
请键入 NET HELPMSG 2182 以获得更多的帮助。
C:\WINDOWS\system32>d:
D:\>cd D:\Program Files\MySQL\MySQL Server 8.0\bin
D:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -hlocalhost -uroot -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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>
刷新刚才修改的权限,使其生效。