I have recently upgraded my staging database server from MySQL 5.0.84 to 5.1.72. I am trying to restore the mysqldump after upgrade. The database name in the dump is gss-app
. But the database folder name under /var/lib/mysql
turned to be gss@022dapp
, but when I login to mysql using mysql -u root -p
and type show databases;
it lists the database name as gss-app
only and I can Use Database gss-app
and list the tables using show tables
command.
The restore was failed with an error Got a packet bigger than --max_allowed_packet size
. That time the database was partially restored and I took that chance to rename the gss@022dapp
folder to gss-app
and logged into mysql shell.
It listed the database name as @mysql@gss-app
and I was not able to get into the database. Now I'm running the database restore once again with --max_allowed_packet_size=1024M
and I see the gss@022dapp
folder was created in /var/lib/mysql
.
Should I concern about the folder name in /var/lib/mysql
? Or can I use a different database name while restoring?
Specifically to your question about using a different name while restoring: with mysqldump you can either do
mysqldump databasename
ormysqldump --databases databasename
. The former doesn't put acreate db
statement in it, the latter does.When you have made the dump with the former statement, you can just manually create a new db and load the dump with something like
mysql newdbname < dump.sql
. In case of the latter, you can just open your dump file and change the name.A sidenote, I think it's bad design on MySQL's
mysqldump
part to have this difference, BTW. If you backup without the--databases
statement, you have to make a database first before you can restore. And that database might have a different charset or collation than what the database originally had. In my opinion, if you dump a database, it should contain all data and metadata. Same goes for having to supply--routines
and--events
. I can imagine options like--no-routines
can be handy, but by default not dumping routines? Hmm.