Unknown database 'test'

Nov 17, 2012 at 1:44 PM

Issue :

Unknown database 'test'

 

When Backup database and delete orignal database and try to restore then generates error!!

 

If any suggestions from ur side then very helpful for me ...........

Developer
Nov 20, 2012 at 8:03 AM

try to backup your database with AddCreateDatabase property set to true.

 

Coordinator
Nov 20, 2012 at 3:22 PM
Edited Nov 20, 2012 at 3:24 PM

Hi, fourteen_naveed,

Deleted database is not existed. If you initialize a connection to MySQL database like this (example):

server=localhost;user=root;password=1234;database=test;

An MySqlException of Unknown database will occur. MySQL can't find the database defined in connection string (because it is not existed, it had been deleted).

You have to establish a connection to MySQL database without specifying the initial database in connection string like this:

server=localhost;user=root;password=1234;

But, in MySqlBackup.NET version of 1.5.2 beta, it does not support initialization without an initial database. Therefore some changes have been made to fix this.

v1.5.3 was just released. You may proceed the restoration of database with v1.5.3 without specifying initial database in connection string.

Another extra minor changes in v1.5.3 is non-super admin user is allowed to be used with MySqlBackup.NET. In older version, v1.5.2 or older, only super admin user is allowed to used in MySqlBackup.NET, or else an user privilege of MySQL exception will occur during processing Stored Procedure, Stored Functions, etc.

Now, if the MySQL user does not has super admin privilege, the backup will still able to carry out, but without exporting Stored Procedure, Stored Functions, Triggers, Events and View.

Nov 22, 2012 at 5:09 PM

Hi,

I have just been in the same situation and think I might have found a soultion.
I backed up the database with the AddCreateDatabase = True and then deleted it. But when trying to restore it I got the error "unknown database 'testdatabase'".
Looked in the sql backup file and found these lines:
"CREATE DATABASE IF NOT EXISTS `TESTDATABASE`", ('testdatabase' is in capital letters)
USE testdatabase;

I removed the "ToUpper()" from the following line in MySqlBackup.NET:
_createDatabaseSql = dtDB.Rows[0][1].ToString().ToUpper().Replace("CREATE DATABASE", "CREATE DATABASE IF NOT EXISTS") + ";";

Now everything works :-)

Coordinator
Nov 23, 2012 at 6:39 AM

Hi madsandrup,

thanks for pointing out the bug.

This bug is fixed in released of v1.5.4. Available at [Downloads].