MySQL Restores Failing

I’m struggling with a problem with backup and restores on one of our systems… I can’t seem to track down what’s going on here and hoping someone can help without needing to open a support case.

When I do a backup of a virtual server (only Apache and MySQL configured for the virtual server) and do a restore, it always fails to connect to the MySQL database when trying to recreate it. I "untarred" the backup and checked the .backup/<username>_webmin file and it looks like the username/password is correct, but the output when trying to restore says that access denied when connecting to username @ localhost. I can use mysql to connect to the database from the shell just fine.

I even tried to create a whole new virtual server to test with. I did a default Drupal install, backup and restore. When it restored, it did the same thing. All the files were there in the home directory, I was just missing my MySQL data (database and user do exist).

The admin password and MySQL password are the same, and when I created the new server I left it that way as well.

I can then use the “execute SQL” option in Virtualmin to restore the database after I extract it from the tarball, but that’s less than ideal.

Server is: Virtualmin 3.67 Pro and Ubuntu 8.04, fully patched.

Thanks for any help!


So, just to verify, if you type this from the command line:

[code:1]grep pass= /etc/webmin/mysql/config[/code:1]

Is that the root MySQL password that you’d expect? Does that password work if you type “mysql -u root -p” and enter the password when prompted?

Thanks for the quick response.

The password in that file is indeed correct. I am able to connect as root to MySQL with it.

From the output it looks like it’s trying to connect to MySQL as the user, however. Is that not the case?

You may be right, and you did mention that above, I was just making extra sure! :slight_smile:

I honestly have no idea what might cause what you’re seeing – I’m going to ask Jamie if he can take a peek at your issue.

One thing to check is if you have a /root/.my.cnf or /.my.cnf file on your system. In some cases, if this contains a password= line which is incorrect it can override the password Webmin tries to use to connect to MySQL.

If this file exists, either delete it or remove or correct the password= line.

Should I look for that .my.cnf file in the home directory of the user I’m trying to run the restore as or in root’s home directory?

I guess I’ll answer my question quick… I didn’t find a .my.cnf file in /root, /, or the user’s home directory.

Thanks for your help

Just for fun, if you ran a "find" on the entire system, does that show anything? You can do that with:

find / -name .my.cnf


Didn’t find anything :frowning:

Another thing you can try is going to Webmin -> Servers -> MySQL Database -> Module Config, and change the ‘Use MYSQL_PWD variable to pass password?’ option to ‘No’.

Didn’t do the trick either :frowning:

Is there a way I can turn on some debug logging?

One more thing to try - go to Webmin -> Servers -> MySQL Database, and make sure that it shows the existing databases on your system correctly.

Sorry, didn’t have time to respond over the weekend.

Are you asking if we can manage the MySQL database from Webmin? If so, yes I can.


Ok … can you use the MySQL module to create and restore backups of databases?

Yeah, I can create backups of the MySQL databases and restore them manually, but the restore doesn’t seem to work when it’s bundled up in a Virtualmin backup.

Are you doing this restore while logged into Virtualmin as root, or as a domain owner?

Hmm well I feel like a bit of a n00b that I didn’t mention that, but yes, I’ve been trying to do this as the domain owner.

It does appear that root (or my user that has sudo access) is able to do a restore. I hadn’t tried that before… (the idea behind utilizing Virtualmin on this server is so users can test upgrades and fail back to a user-created backup without involving one of our admins).

I’ll try to answer the next logical question: when I login as the user trying to do the restore, I am able to manage that user’s databases.

Ok, I see the bug that is causing this now, and will fix it in the next Virtualmin release. If you don’t want to wait till then, you can edit the file virtual-server/ under the Webmin root directory, and change line 491 from :

[code:1]&mysql_user($[0]), &mysql_pass($[1], 1));[/code:1]

to :

[code:1]&mysql_user($[0]), &mysql_pass($[0], 1));[/code:1]

Sweet! Thank you so much!

I’ll make the change and confirm with the user.

Also, you’ll need to restart Webmin after making this change, with the command /etc/webmin/restart