Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

[MySql] Import-Export Database command using Putty

Hello Friends,

I was working with one client who want to migrate MySql 4 to MySql 5. It can be easily done using the Export and Import feature of phpmyadmin. Problem here is with size of database. Size of the database is over 900mb. so phpmyadmin does not allow to import or export the database.

I talked with server people and they told me to use putty and execute mysql command to export the database first which is mysql 4. Once i export it, it will be saved on server. I can use that path of file and import it to mysql 5 database.

Here are the commands.

Export Database Command..

Note : File will be saved under the current directory. To check the current directory, type psw and press enter. You can see the current directory name.

mysqldump –no-create-db=true -h localhost -u username -p databasename > filename.sql

Explantion:
–no-create-db=true – This will be used for single database.
localhost – Host name
username – MySql Username
databasename – Database name which you want to export
filename.sql – Filename which you want to export as..
Do not need to enter password in command line. Once you type this and enter, it will prompt you for password. Simply type the password and enter. (You can not see when you type password so type and enter.)

Import Database Command..

Note : You should be in same directory where your exported file is located. To check where you are, type psw and enter. If you want to move to any directory, type cd directory name and enter.

mysql -h localhost -u username -p databasename < filename.sql Explantion:
localhost – Host name
username – MySql Username
databasename – Database name where you want to import
filename.sql – Filename which you want to import..
Do not need to enter password in command line. Once you type this and enter, it will prompt you for password. Simply type the password and enter. (You can not see when you type password so type and enter.)

Isn’t it easy to work with putty ? Migrate MySql 4 to MySql 5 using Putty, Export Database with putty, Import Database with putty, Export Database with mysql command, Import Database with mysql command can be easily done.

Share:

1 Comment

Leave a Reply

Your email address will not be published.