[CentOS] Using Mariadb databases from old server

Fri May 29 13:39:57 UTC 2015
Todor Petkov <zakk at online.bg>

On 29/05/2015 02:00 PM, Timothy Murphy wrote:

> 
> I did add something to Mariadb on the new CentOS-7 system,
> but I don't mind deleting it and starting again.
> I can mount the partition with the old mysql files on it.
> Could I just copy the contents of /mnt/var/lib/mysql
> to the new system?
> There are files with the same name, eg ibdata1, on both systems.
> Could I have an ibdata2 ?
> 
> Any suggestions gratefully received.

If you don't care about the new data, you can:

1) shut down MariaDB
2) rename /var/lib/mysql to /var/lib/mysql.orig
3) copy the old directory /var/lib/mysql - /mnt/var/lib/mysql in your 
case  - do not forget the permissions! - to /var/lib/mysql
4) systemctl start mysql (or mysqld, can't remember)
5) run mysql_upgrade - this is a script, which changes the mysql.user 
etc tables with the new columns
6) There are some issues with PHP for example, when you have an user in 
mysql system tables, that has an old hash password, so you need to 
reenter the password to update the hash

I did it many times this way and everything went smoothly.

Good luck and don't forget to make some backups just in case;)