Support

Akeeba Backup for WordPress

#24374 Unable to connect to the Database: Could not connect to MySQL.

Posted in ‘Akeeba Backup for WordPress’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

WordPress version
n/a
PHP version
n/a
Akeeba Backup version
n/a

user27991
Hi
I have been trying to work out why I am unable to connect to a database when restoring a backup to an 'empty site'.
(Empty sites = in both cases hosting space where no exisiting content exists. )
1. Original site is hosted on an Indian server which went down - deleting content so tried to restore backup which was on dropbox.
Am experienced user of Akeeba backup on Joomla so created new database etc.
Tried everything but still got message 'Unable to connect to the Database: Could not connect to MySQL.'

2. Decided to experiment on our own virtual server from Vidahost where we have often backed up and restored Joomla using Akeeba. Created a 'test-site' on a subdomain - same problem.

Just to see if for some reason the backups were corrupt - I downloaded file to my computer and restored them offline using Xampp.
This worked fine and was able to connect to database.

I then tried using the Duplicator plugin.
This installed the site with no problems.

So have no idea what the problem might be.

Andrew

nicholas
Akeeba Staff
Manager
The part of the restoration that you describe is common between the Joomla! and WordPress restoration scripts. The message will appear when any of the database connection information is incorrect. The most common causes for that and ways to deal with them are explained in https://www.akeebabackup.com/documentation/troubleshooter/abidatabase.html

The usual problems we are seeing:
  • Entering the db information in a hurry, therefore mixing up the server hostname with the username or the username with the database name. I know it sounds silly but it's easy to become blind to the form labels once you start entering the wrong information. I've done that with WordPress "famous 5'installation" several times ;)
  • Database server hostname localhost vs 127.0.0.1.
  • Complex passwords including special characters being filtered out by the web server (ironically, the most secure database server passwords are considered potential attacks by the most commonly used mod_security2 rule sets).
  • Users simply forgetting to add the prefix imposed by cPanel in the user and database names.


In 100% of cases where I was given cPanel details I found out that I could perform the database restoration that the client described as impossible with the very first try – all I had to do was make sure I'm entering the correct database information in the correct fields.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user27991
Hi Nicholas
Thanks for replying on a Sunday!
It was solved!
I explain what I was doing for other users and what solved it!
Background
I have been assisting a non-profit in India which has had a terrible time with their hosting company, essentially the server has gone down 3 times in the last 2 months losing all their content.
They had no backup system I 'trusted' - and althought I work mostly in Joomla - I felt I could trust Akeeba with their Wordpress backup!

Akeeba worked - but...
I installed Akeeba Wordpress plugin. And set it up so it would backup to Dropbox. With a Cron job so it was done weekly.
No problem - backups were in Dropbox
Hoping if problems arose I could swiftly restore the site.

So 2 days ago server went down!
Wiped the contents of the site - again!
But backups were on Dropbox!

I tried many times to restore - both on the existing server and on a better quality server which I run.
But it didn't work - database wouldn't connect.
Though it did on an Xampp local host on my computer.

Try and try again
Meanwhile, the non-profit and I decided to buy a new domain name - because they had no real control over the exisiting one.
I set the new domain up on 'our server'
And uploaded all the files.
But the restoration again got stuck on problem connecting to Database.

Important
And then I read Nicholas email properly - this part!
Complex passwords including special characters being filtered out by the web server (ironically, the most secure database server passwords are considered potential attacks by the most commonly used mod_security2 rule sets).

So I tried an experiment - changing the password on the DB username I had created - to something more simple (but secure)
And the problem was solved!

An interesting journey!
But solved in the end!
As usual Nicholas provided the answer!
:)

nicholas
Akeeba Staff
Manager
Awesome! I think I have to add a Javascript notification that complex passwords may not work on some servers and link that to a troubleshooter article. I've seen that happening a lot. Usually people aren't as open minded as you ;)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user27991
Hi Nicholas!
I guess the thing is I am always a little nervous posting questions here. And on other software forums because normally we answer is lurking around in another post.
And it must get real tiresome answering the same questions over and over again!
So when something crops up here that doesn't appear to have been answered elsewhere I always take special note of what you say.
Thanks mate - and keep up the good work!

Andrew

Support Information

Working hours: Typically we work Monday to Friday, 9am to 7pm Cyprus timezone (EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets, but we cannot respond to them, outside of our working hours.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!

Summer vacations: Our support will be closed for replies and new tickets from August 6th to August 21st, 2022 due to summer vacations.