Monday, May 10, 2010

How to load MYSQL Database from Command Line in Linux and XAMPP

To load a Mysql file from the command line to a certain database you can use the following command


mysql -u root -p joomla < backup.mysql


This works in linux environment where joomla is your database name.  Best to be in the same directory as the mysql file and you can load it without typing the path to the file.


If you are hosting in your own Xampp in Windows, there is also a way to load your mysql file from the command line, in my example I would assume that you have installed Xampp in 


c:\Xampp,


 thus the directory for mysqld would be


c:\Xampp\mysql\bin


then if you put your mysql file in the same directory, you can load it directory from that directory if you haven't had your path set.  Type


mysql --user root --password joomla < backup.mysql


It will prompt you for a password then your mysql will be loaded depending on how big your backup is. you could add a -f flag if your database is very big, it will prevent it from stopping if there is error. 


mysql -f --user root joomla < backup.mysql


Enjoy

1 comment:

Anil IT Expert said...

I will share it with my other friends as the information is really very useful about Xampp. Keep sharing your excellent work. how to change port number in xampp server