Host '10.0.2.2' is not allowed to connect to this MariaDB server

Host '10.0.2.2' is not allowed to connect to this MariaDB server
mysql的root用户,默认只允许本地访问。当使用客户端连接远程mysql服务器,出现上面错误。只要在mysql.user表添加远程用户即可.
  • 进入mysql命令行界面
➜  ~  mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  • 执行下面insert
insert into mysql.user(Host,User,Password) values("%","root",password("root"));insert into mysql.user(Host,User,Password) values("%","root",password("root"));