问题
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