backup the database using MySql - mysql

hi i want to backup my MySql database,
i write this command :
mysqldump -u root -ppassword -h localhost --all-databases > backup.sql;
and it give this error:
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
dump -u root -pmanager -h localhost --all-databases > backup.sql' at line 1
why?
and what should be do?
thanks...

You are running this command in mysql. You should be running it from the command line instead.

Related

Getting syntax error while exporting mysql database

I have cPanel trial version installed on the centOS server which is expired now. So I don't have access to cPanel user and WHM login.
I am tried the following
mysql> mysqldump -u root –ppassword db_name > db_nametext.sql;
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 -u root –ppassword db_name > db_name at line 1
Thank you for time and consideration.
You cannot run mysqldump from mysql shell: mysqldump is not a SQL statement but an executable that must be run from linux shell like mysql command.

mysql: unable to use mysqldump on production

I tried below commands,
mysqldump -h 127.0.0.1 -u username -p db_name > dumpfile.sql;
mysqldump -u username -p password db_name > dumpfile.sql;
mysqldump db_name > dumpfile.sql;
It always throw this error:
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 ..' at line 1
mysql version: 5.7
You should launch this command from CLI as it's a separate binary executable. According to the message you get you trying to execute it as SQL command and it's totally incorrect.

How to export .sql file in MySQL database using MySQL commandline client?

How to MySQL server database export .sql file using command line?
I have used below commands,but shows in syntax error
mysqldump -h ipaddress -u username -p password> mysqlfile.sql
I have below Error:
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 'mysq
dump -h 192.268.1.17 -u root -p root> mysqlfile.sql' at line 1

Can't backup with MariaDB Console

I am trying to take a backup of a database. I open up the MariaDB client console on windows 10, enter root password and then enter this:
MariaDB [(none)]> mysqldump database_name > backup.sql;
It returns this error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'mysqldump database_name > backup.sql' at line 1
What did I do wrong?
Try using
mysqldump -u root -p database_name > file.sql
before logging to database (new CLI window). You will have to enter root password after this command
You should be able to run this command in any CLI, like CMD.exe or Git Bash - depending on the way you installed things on your machine. I hope this helps

Got an error on mysql database backup time

I have mysql database (mysql Ver 14.14 Distrib 5.5.28, for Linux (x86_64) using readline 5.1) on my host server. I want to take backup using SSH. So I login by root user and go to mysql and write the command as below
mysql> mysqldump -u username -p password --opt dbname > filename.sql;
but this didnot work for me and gave me and error like
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 --u username -p password --opt dbname > filename.sql;' at line 1
Can any one provide me a solution to me to make a backup.
I am making a backup on server directory.
Your problem is that you're trying to execute mysqldump from the mysql CLI.
mysql> mysqldump ...
^^^^^^
First exit mysql
mysql> exit
Bye
username$
and then in the command prompt start mysqldump on its own
$ mysqldump -uusername -p"password" --opt dbname > filename.sql;