I was left wondering because you mentioned SSH which implied connecting from your database server to a different machine (free tip: You use "SSH" to connect to a machine, but the things you type after that are "shell commands", not "SSH commands." I googled that phrase just now and was horrified at how frequently they're improperly called "SSH commands") ... and in Sqlbot's world, a "slave" is a different machine -- a replication slave -- which also was initially confusing.
You mentioned MYD
and MYI
files but not IBD
files, so either you are using MyISAM and not InnoDB, or you're using a mix but you never set innodb_file_per_table = 1
.
Your path to recovery depends on whether you are using InnoDB.
If you're not using InnoDB
, then you can -- believe it or not -- just copy the old database directories and files into place and fix the permissions if needed. MySQL is extremely forgiving about this with MyISAM
tables.
Connect to your MySQL server and locate the data directory. From an old CentOS machine of mine (probably still the same for you):
mysql> show variables like 'datadir';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| datadir | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.00 sec)
Find the comparable directory on your old hard drive, and copy all of the directories -- but not the files, and not the "mysql" directory -- into your datadir (probably /var/lib/mysql).
Then, if the files aren't owned by the "mysql" user,
root@host# chown -R mysql:mysql /var/lib/mysql
Then see if it worked.
mysql> SHOW DATABASES;
If you are using MyISAM
only, your databases and tables should be on the new server, though you will need to do CHECK TABLES
on all of your tables or use the mysqlcheck
utility to verify that they are all intact and repair them as needed.
If you're using InnoDB
, the steps will be different, so see if this works for you.