psanjib
psanjib

Reputation: 1301

How to export database through putty?

I have large db so I want to export db by using putty.

Step -1 - connect to mysql

mysql -u username -p -- DBname

Then it will ask to input password. After putting password now my console is ready to execute mysql command

Step - 2 - to export db, I have tried

mysql -u username -p --dbanme > path/folder.sql

it's not working, I get error:

showing ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near mysql -u griar_riar -p --griar_riar > path/folder.sql

I have also tried:

mysql -u username -p -- dbname > /path/folder.sql

mysql -u username dbname > /path/folder.sql

I have also tried mysqldump:

mysqldump -uuser_name -ppassword -hhost_name db_name > /path/folder.sql

Please help me

Thanks

Upvotes: 0

Views: 18143

Answers (3)

Atul Baldaniya
Atul Baldaniya

Reputation: 879

> mysqldump -h your_host_name -P your_port_number -u your_user_name -p database_name > "/var/www/html/dbs/database_name.sql"

follow full syntax by providing hostname and port name it should works.

Upvotes: 0

Fabian Schmengler
Fabian Schmengler

Reputation: 24551

Leave out step 1 and use mysqldump directly on the shell, it is a console tool, not a MySQL command.

Upvotes: 3

maxhb
maxhb

Reputation: 8845

Use mysqldump, it's the right tool:

mysqldump -u USERNAME -p NAME_OF_DATABASE > /path/to/file/export.sql

Substitute USERNAME, NAME_OF_DATABASE and /path/to/file/export.sql to fit your needs/enviroment.

mysqldump will require you to enter your password and then export your data.

If username is pigeon and database name is airport then this will export all your data

mysqldump -u pigeon -p airport > /path/to/file/export.sql

Upvotes: 2

Related Questions