mysqldump error in exporting a table from a database - mysql

Can anyone please let me know why am I getting this error
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 -p --user=root database_name utilities > utilities.sql'
on this mysqldump -p --user=root database_name utilities > utilities.sql;
I tried keeping the database name, table name in backticks. Nothing seems to work.

mysqldump should be run from a normal command prompt/shell instead of the mysql command, not at the mysql prompt inside it.
ubuntu-vm:~$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.31-0ubuntu0.13.04.1 (Ubuntu)
mysql> exit
Bye
ubuntu-vm:~$ mysqldump -help
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
ic#ubuntu-vm:~$

Related

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

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

dumping DB in mysql

when I run below statement, mysql is complaining having error.
mysqldump --triggers --routines -u root -p mydb > mydb_20120924.dmp;
mysql version: 5.1.34
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 --triggers --routines -u root -p mydb > mydb_20120924.dmp' at line 1
It looks like you are trying to run the mysqldump command from inside the mysql command line interpreter.
Does the prompt for the mysqldump command say 'mysql> '? Then you are running the mysql command line interpreter. It should be used - indeed, it can only be used - for running mysql commands.
mysqldump is a separate command and must be run from the shell.
Quit mysql by typing "exit" - you will see a shell prompt. Then the mysqldump command will work.
If you have a database called "mydb" this should work. You could try using --database specifically:
mysqldump --triggers --routines -u root -p --database mydb >
mydb_20120924.dmp;

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.