MySQL允许远程访问

如果mysql没有设置允许远程访问时进入远程访问就会报错:

_mysql_exceptions.OperationalError: (1130, "Host 'x.x.x.x' is not allowed to connect to this MariaDB server")  

就要修改mysql数据库的访问权限:

mysql>use mysql;  
mysql>update user set host = '%'  where host ='root';  
MariaDB [mysql]> update user set host = '%' where host = 'localhost';  
mysql>flush privileges;  
mysql> select host, user from user;  
mysql>quit  

当然不用了也要改回去了:

mysql>update user set host = 'localhost'  where host ='%';  
MariaDB [mysql]> update user set host = 'localhost' where host = '%';