I have a simple question please
When I put data into the local host server's database via python, i do the following
db= MySQLdb.connect("localhost", "root", "pass", "Database")
Now i have just for a hostgator server which me and my friend share
The snapshot of the Cpanel's database section is as attached.
Now what should i input in the following code for connecting to the database
db= MySQLdb.connect( , , ,)
I have tried this but failed]
db= MySQLdb.connect("moeenmh.com","moeenmh_ahmed","<mypass>","moeenmh_ahmed")
The user I created for my self is moeenmh_ahmed and have a password for it]
Error is "Access denied for user 'moeenmh_ahmed'@'91.74.98.6' (using password: YES)")
Your database name has to be the full name, not just the _ahmed
part. So it should be moeemnh_adhmed
. Protocol should be 'TCP' for remote connections.
Also, check if you have configured MySQL for remote connections. So first try to connect to it using:
mysql -u moeenmh_ahmed -h moeenmh.com -p
And see this SO answer for setting up the privileges: https://stackoverflow.com/a/12844804/1431750 . Quoting:
You have to put this as root:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD';
where IP is the IP you want to allow acess and USERNAME is the user you use to connect
If you want to allow access from any IP just put % instead of your IP
and then you only have to put
FLUSH PRIVILEGES
or restart mysql server and that's it
I can see from the Cpanel screen shot that moeenmh_ahmed doesn't have access to moeenmh_ahmed DB. You can see in Cpanel documentation how to do it: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/MySQLDatabases#Define a User's Privileges
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.