Zub
Zub

Reputation: 27

Copying database backup files from xamp/mysql/data of windows to linux in path /var/lib/mysql

Copying database backup files from xamp/mysql/data of windows to linux in path /var/lib/mysql, but it is creating only empty database in phpmyadmin of linux.

Please some one help me to solve this issue, i have only these files backup with me

Upvotes: 0

Views: 1184

Answers (2)

sjas
sjas

Reputation: 19757

First create a .my.cnf file containing the mysql root password in your users home folder, on linux. On windows, there exists a .my.ini or something which serves the same purpose. That way you will not have to reenter your passwords a lot during the next steps, which you are very likely to repeat several times until you get them right, I fear. :)

Since unix/linux and windows have different ways to save files, you might very likely run into errors during a simple copy-restore process, depending on how you copy files.

Your best bet is likely copying the original mysql folders to another windows machine and save them accordingly, such that mysql can find them. (With an installed mysql instance, of course.) I don't know what else you might need, if the databases are not found instantly, since I never had to do this prior and have no test setup here to check this case out.

When the databases are found through the mysql on the WINDOWS server, from the mysql cli prompt there look up which encoding etc the db uses:

SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;

Then create a new database on the LINUX server with the same name and the same encoding's from MYSQL CLI:

create database <db-name> character set <charset> collate <collation>;

Then on the WINDOWS server in a CMD window, do a mysqldump which should look familiar on windows like on linux:

mysqldump  <db-name>  >  <db-name>.sql

Then copy the dump over to the LINUX server and replay it:

mysql  <db-name>  <  <db-name>.sql

Afterwards you will have to recreate a user (if you know which user and password your web app used to access the database, create a new user with these credentials and grant him full access on your database.

If you do not happen to know the credentials anymore, create an arbitrary user and then change the database credentials in the configfile of your web application.

In case you have problems, check the unix file permissions of the files you copied, such that mysql can access them.

Good luck, mate.

Upvotes: 0

Zafar Malik
Zafar Malik

Reputation: 6854

The best way is-

Step1: Take backup from windows by mysqldump-

mysqldump -uroot -proot123 -A > backup.sql

Step2: Move this backup to linux, you can use winscp tool for it.

Step3: Now restore this backup to linux machine.

mysql -uroot -proot123 < backup.sql

Modification: It seems your db engine is myisam and you just coppied file/folder from window to linux, so give permissions as per below-

chown -R mysql.mysql /var/lib/mysql

Upvotes: 1

Related Questions