1

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.

enter image description here

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)")

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
user3265370
  • 121
  • 1
  • 2
  • 12
  • Are you sure you are using the `password` of mysql database or your `account` password? Most of the time the hosting services provide a username and password which is relative to your web app or account. But the account password and the mysql password is different. You might wanna check that out. – Xk0nSid Apr 02 '14 at 09:44
  • i am using the pas of the user i created. the other pass is Cpanel's password – user3265370 Apr 02 '14 at 09:47
  • It's obviously is some kind of access rights issue. You can probably conatact Hostgatr tech support since they will know what kind of access rights are given and in what case access is denied cuz they know the server configuration while we don't. It may help. Also try ssh into your hosting (if the rights are given) and try using mysql command line program to login into the database. If it works there, then it's obvious that you don't have remote access. – Xk0nSid Apr 02 '14 at 09:52

2 Answers2

0

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

Community
  • 1
  • 1
aneroid
  • 12,983
  • 3
  • 36
  • 66
0

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

asafm
  • 911
  • 6
  • 17