I have a MYSQL database with users table, and I want to make a python application which allows me to login to that database with the IP, pass, username and everything hidden. The thing is, the only IP which is allowed to connect to that mysql database, is the server itself (localhost).
How do I make a connection to that database from a user's computer, and also be able to retrieve data from it securely? Can I build some PHP script on the server that is able to take parameters and retrieve data to that user?
You can use below code into your python script to connect your application with remote mysql database.
import MySQLdb myDB = MySQLdb.connect(host="x.x.x.x", port=3306, user="**********", passwd="*****************")
You need to install mysql-python to connect your python application with mysql database.
As i understood you are able to connect only with "server itself (localhost)" so to connect from any ip do this: mysql> CREATE USER 'myname'@'%.mydomain.com' IDENTIFIED BY 'mypass'; I agree with @Daniel no PHP script needed...
You should not make a connection from the user's computer. By default, most database configurations are done to allow only requests from the same server (localhost) to access the database.
What you will need is this:
That is basically, what you are trying to achieve.
Hope the explanation is clear and it helps.