mysql支持远程访问

本地ip为192.0.4.138,远程访问是报错,如下:

ictester@ic-tester:~$ mysql --host 192.0.4.138 -u root -p12345
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1130 (HY000): Host '192.0.4.133' is not allowed to connect to this MySQL server

需要开启远程权限,

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

上述错误是因为设置的密码太简单了,

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)

然后再执行:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

此时远端可以正常访问了

mysql --host 192.0.4.138 -u root -p12345
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • win7 cmd管理员权限设置 net localgroup administrators 用户名 /add 把“...
    f675b1a02698阅读 10,740评论 0 11
  • 运行操作 CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本、文件系统版本) CM...
    小明yz阅读 7,900评论 0 8
  • 一、命令行 1. calc-----------启动计算器 2.certmgr.msc----证书管理实用程序 3...
    小小辛_c阅读 3,968评论 0 2
  • 运行操作 CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本、文件系统版本) CM...
    小沐子_IT阅读 7,828评论 0 4
  • 命令简介 cmd是command的缩写.即命令行 。 虽然随着计算机产业的发展,Windows 操作系统的应用越来...
    Littleston阅读 8,574评论 0 12