I have a website hosted at godaddy (say "abc.co.in"). After having logged into cpanel through my cpanel id and password (say "siteid" and "sitepw" respectively), i went ahead and created a MySQL Database named "myDb". Now i assigned a user to that database and granted all privileges. Say my database user id and password are "dbUser" and "dbPw" respectively.
Now i want to Add a table to this database using php.. However, upon connecting, using the following code:
$con=mysqli_connect("abc.co.in","dbUser","dbPw","myDb");
i get an error :
Warning:mysqli_connect():(HY000/1045) - Access denied for user 'dbUser'@'xxx.xxx.x.xxx' (using password: YES)"
Now i read somewhere that my user name needs to be of the format "cpanel-username_mysql-username", i.e., in this case: "siteid_dbUser", whilst password still sticking to the database password. However, It still returns me the same error message.
Am i typing the first parameter, 'hostname' incorrect? It doesn't need to be "localhost", does it?
Kindly help for i am gravely confused. I know it might seem like a repetitive question but i checked a lot of posts here but couldn't find a solution..
Thanks in advance!
--EDIT--
Just for the record, the php file in which i'm trying to establish the connection and trying to add a table to my database is a local php file running on localhost. Just thought i'd mention it, incase it makes a difference.
--EDIT 2--
Okay so according to THIS link, even my database name needs to change.. hence modifying my code to
$con=mysqli_connect("abc.co.in","siteid_dbUser","dbPw","siteid_myDb");
I tried it out but all in vain.. Still the same error message. I even changed the host to "localhost" and tried the same but it just doesn't connect.
localhost
, it will not work if you are trying to connect via192.168.1.X
. It might not even work with127.0.0.1
– Russell Uhl Jun 25 at 12:48