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

Logging to my MySQL server with PHP

I have been running this same script for over a year and 5 days ago it stopped working. It connects to my MySQL server using my cpanel username and password. Now the script keeps failing.

 

I was on the phone the last 2 days for a total of 3.5 hours. A ticket was opened yesterday but it was closed today. Support says everything is woking OK. Thay said nothing has changed.

 

These are the statements in my script:

$link = mysqli_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysqli: ' . mysqli_error($link).'\r\n');

 

The error I get is: [06-Feb-2020 18:20:03 UTC] PHP Warning: mysqli_connect(): (28000/1045): Access denied for user 'MYCPANELUSERNAME@'localhost' (using password: YES) in /home/tif0qktaow5f/public_html/DB_Backups_Test/Includes/load_array_databases.php on line 14.

 

Any suggestions wil be greatly appreciated as I am using the script to do a daily backup of my databases.

1 ACCEPTED SOLUTION

@garykoz 

 

Thanks for sending me the script - I tested it on my VPS/cPanel account and it worked - I uncommented the echo row and got the 2 Databases listed in my account.

 

Can you double check that you are running PHP 7.x and it didn't somehow revert to PHP 5.x - something still seems strange that it is the password issue.

 

From SSH can you get into mysql via 

mysql -uCPANELUSER -pCPANELPASSWORD

 

If not try resetting your cPanel password and trying again

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

View solution in original post

10 REPLIES 10
Super User IV

@garykoz 

 

While this may sound obvious have you tried to reset the password / permissions or create a new user

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Because it is my cpanel login all I can do is reset my password.

@garykoz 

 

On the cPanel account you should be able to go to "MySQL Databases"

 

From here you can add the user to the database (even if they are already added) and grant all permissions

 

You can also reset the password for the user as well as create a new user and assign that user to the database.

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

I am not having trouble accessing my individual databases with a script. I
am trying to go one level deeper and access the names of all tables.

My script used to get the names then does a sql dump of the database to a
file. This is so I can get a daily backup of my SQL databases.

@garykoz 

 

Going back to your original post the error was that it is giving you is that it is a password / user issue.

 

To the best of my knowledge with cPanel - it's not the cPanel username but rather the user name you created when you setup the database. Hence the reason I asked about the user / password.

 

Can you post any more of the code ??

 

Also I guess I'm confused unless you are dumping each table individually you could run a cron job to do the dump

 

Local Host mysql Backup:
0 1 * * * /usr/local/mysql/bin/mysqldump -uroot -ppassword --opt database > /path/to/directory/filename.sql

(There is no space between the -p and password or -u and username - replace root with a correct database username.)

 It just seems like extra work to do this via a PHP script.

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

I am trying to connect at the server level not the database level. This
connection was working up until last Tuesday.

This script is an include in 2 other scripts. They allow me to either dump
all my databases or just certain ones to a file. Then each file is
processed into a zip file which is then email to me. This allows me to get
a dump of my data either from the cron job that runs every night or from a
manual run of the script.

By doing it the way, I am the script automatically reconfigures itself when
I add or delete a database.

Is there some other way to connect that I can use?

@garykoz 

 

1) are there any errors that you can find other than what you posted?

2) If you try to run the script manually via the command line (outside of PHP) what do you get

3) Did anything change on the server last week ??

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

1) No I don't think there are any errors other than the I get from the
script. Where else could I look to find them?

2) I'm not sure how to run a script outside of PHP. I can connect to the
server with SSH. If you could explain how, I'd sure give it a try.

3) I have talked extensively with GoDaddy support and they say nothing has
changed on their end. This is a script that I have been using for over a
year and have not had a need to touch it.

Here is the script.

@garykoz 

 

Thanks for sending me the script - I tested it on my VPS/cPanel account and it worked - I uncommented the echo row and got the 2 Databases listed in my account.

 

Can you double check that you are running PHP 7.x and it didn't somehow revert to PHP 5.x - something still seems strange that it is the password issue.

 

From SSH can you get into mysql via 

mysql -uCPANELUSER -pCPANELPASSWORD

 

If not try resetting your cPanel password and trying again

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

View solution in original post

PHP was set to 5.6. I reset it to 7.2 but got the same error.

I reset my password and it is working now.

Thank you so much. I guess I couldn't see the forest for the trees with my
password.

Again thank you so much. This has really been bugging me. Probably being a
stubborn Polak doesn't help either.