How to export database through putty? - mysql

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

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

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

> 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.

Related

Backup clearDB database to local

I am trying to backup and restore the cleardb database. I was trying to backup to my local computer first and then restore it. However, I am not able to create a backup
mysqldump -h us-csdr-fern-sds-03.cleardb.net -u sdloremipsum5 -p ipsum <my_dev_dump.sql
I am trying this from mysql shell but I get
Syntax Error: Unexpected Identifier
use
mysqldump -u username -p databasename > filename.sql
to export and
mysql -u username -p databasename < filename.sql
to import
Please refer: http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html
Duplicate: Syntax error in mysqldump command
Answer: https://stackoverflow.com/a/18502626/10368530

Unable to export entire db

I'm unable to export my database.
I have tried several times unsuccessfully including:
mysqldump -u root -p --opt --db_2 -r backup.sql;
and
mysqldump --database --user=root --password db_2 > export_into_db.sql;
I get this error with both of them:
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 'mysqldump --database --user=root --password db_2 >
export_into_db.sql' at line 1
For anyone who is using mac you need to do the following steps in order to export the sql:
1.open a new terminal window
2.type this to enter the mysql if your unable to enter it PATH=$PATH:/usr/local/mysql/bin
3.mysqldump -u root -p db_2 >/Users/your_name/Desktop/sql.sql;
4.type password

How to backup stored procedure backup from Google Cloud SQL?

I want to create/export only the stored procedures from my Google Cloud SQL DB. I tried several commands on my phpmyadmin(installed on Google App Engine) console but I am consistently facing the error mentioned below.
List of commands I've tried:
1. mysqldump --routines=true -u root sarda_yogi_mobile > my_database.sql
2. mysqldump --databases database_name [-h instance-ip -u username -p password] \ --hex-blob --default-character-set=utf8 > database_file.sql
3. mysqldump --databases database_name [-h instance-ip -u username -p password] --default-character-set=utf8 > database_file.sql
4. mysqldump --host="127.0.0.1" --user="root" --password="" --routines --triggers --events dbname > my_file.sql
Error Message:
#1064 - 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 'mysqldump --routines=true -u root db_name > my_database.sql' at line 1
Can anyone point me in the right direction? Thank You :)
As #Vadim said, you're attempting command-line statements at a SQL shell, which (as you've seen) doesn't work.
To perform a stored procedure export from within phpMyAdmin, go to the "Routines" tab of your database and click "Export" for the routine you wish to export. You could instead use the checkboxes to select several to export at once, if you prefer.
Those are commands you need to run on a command line, not via the phpMyAdmin shell.
If you want to perform an export from phpMyAdmin, there are some guides available on the web, e.g. http://www.inmotionhosting.com/support/website/phpmyadmin/export-database-using-phpmyadmin

MySQL dump inside mysql console

Is there SQL command where you can do MySQL dump inside the MySQL console?
I tried mysqldump but it does not work...
I'm trying to output into SQL file.
You cannot run mysqldump within a MySQL console since mysqldump is an external command like the mysql console.
Exit the console and use the mysqldump command as follows:
mysqldump -u username -p -h hostname (or ip address) databasename > sqlfilename
It will ask for password.
More details of mysqldump can be found at http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
use \!:
\! mysqldump -u username -p database > database_dump.sql
MySQL Documentation Reference (see System command)
use:
mysqldump -u username -p database
database: name of database
username: dbuser

mysql dump error

I'm having some difficulty with mysqldump. I locked my tables and ran the following command:
mysqldump -u user -p password databasename using my actual password and database name.
When I run this from mysql I get a 1064 error that says there is an issue with my syntax. I've also tried running the command from terminal (outside of mysql) and receive a 'command not found' error message. I'm not entirely sure how I should be doing this (the explanations I've found so far have been vague).
Thanks for the help.
The mysqldump is a program, it cannot be executed from the mysql console. Run it from the shell.
Have a look at the syntax reference.
--user=user_name, -u user_name
--password[=password], -p[password]
As you see there is no space between -p and password. So, your command line should be like this:
>shell mysqldump -u <user_name> -p<user_password> ...
or
>shell mysqldump --user=<user_name> --password=<user_password> ...
You are missing the target backup file name:
# [mysql dir]/bin/mysqldump -u username -p password --databases databasename > /tmp/databasename.sql
MySQL Commands
the correct syntax is
mysqldump -u [username] -p[password] [databasename] > [backupfile.sql]
you should add the > backupfile.sql
the other error is believe your system doesn't recognize the mysqldump path and you should go directly to bin folder from mysql installation.