cancel
Showing results for 
Search instead for 
Did you mean: 
Go to solution

connecting to a mysql db thru php

hello, 

New to cpanel, I had an old hosting account on a shared linux server, everything worked great, I moved over to cpanel and it is not going so well, I backed up my mysql db, restored it , all rows show up in cpanel.  I changed my login script to indicate localhost as the servername but It won't let me connect.  I read that I needed to change the usernames password, I tried that and no help.  I have tried both localhost and localost:3306, I have even tried the ip adx 1.1.1.1:3306 (obviously not the actual ip address).  And ideas?  I did go into remote mysql and added my host ip address and even a % just to see if it would help, it didn't.

 

TIA.

4 REPLIES 4
Super User II
Super User II

Re: connecting to a mysql db thru php

@gdgdaddy 

 

So I have a question or two

 

1) How did you create the database on the new server?

2) Did you assigned permissions to the user to the database?

3) Do you have any error code in your PHP to see if it isn't connecting or a bad password or something else?

 

 

GoDaddy Pro User - Managing over 300 WP Sites

Re: connecting to a mysql db thru php

Thanks for replying,

I don't know how I created the database to be honest with you, when I loaded cpanel it was there.  Named correctly?  I wondered how that happened.  I did not assign any permissions yet, how would I do that?  No, I get no mysqli_error ,I have it printing, but nothing shows.

Highlighted
Super User II
Super User II
Solution

Re: connecting to a mysql db thru php

@gdgdaddy 

 

When you are in cPanel there should be a section that has

phpMyAdmin, MySQL Databases, Database Wizard and Remote MySQL

 

If you goto the MySQL Databases, you should have the options to check & repair the databases as well as managing users.

 

Near the top you should see your database and "privileged users"  - I suggest scrolling down to where it says Add User To Database, then you can add the user and on the second screen select all - to grant all the permissions to the user

 

 

 

GoDaddy Pro User - Managing over 300 WP Sites

Re: connecting to a mysql db thru php

assigning the user permissions took care of my problem.  Thank You Very Much.