MySQL is not allowed to connect remotely [duplicate]

99封情书 提交于 2019-12-25 08:57:56

问题


Possible Duplicate:
Remote mysql connection

I've made an C++ app, that requires connection to MySQL db, the error others get when connecting to my MySQL server is: Host is not allowed to connect to the MySQL.

I've been reading some solutions on that, but they require you to have the users ip, how could I allow connection from ANY pc?


回答1:


Create a user with a wildcard (%) as the host name. Here is an example that creates a user named "my_user" and grants them all privileges to the "my_database" database.

GRANT ALL ON my_database.* TO my_user@'%' IDENTIFIED BY 'some_password';

You may want to consider granting fewer permissions. For example, maybe you only need to give this remote user SELECT privileges.

GRANT SELECT ON my_database.* TO my_user@'%' IDENTIFIED BY 'some_password';



回答2:


Best practices would be to put a layer between your database and the outside world. My best choice for this is host a mysql database with a free webhost, then use a PHP script to expose functions that are available to your app using something called a webservice.

From personal experience, there is a NuSOAP libary which will make this ridulously easy. When you are building in Visual Studio, you can add a "web refrence" to your webservice, and it will build the code for you to connect to it.



来源:https://stackoverflow.com/questions/9965101/mysql-is-not-allowed-to-connect-remotely

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!