Does mysqldump utility requires any seperate client ??
I'm using MYSQL5.5 command line client for windows..
I'm writing query
mysqldump -u root -p pwd** my_db > mydb.sql
I'm getting the 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 t
The problem is that you're running the command in the MySQL command line client. Run it from a shell instead, not inside of the client.
In other words, open a normal shell (cmd.exe if using Windows), and run: (your path to mysqldump.exe will no doubt differ)
C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump -u root -ppwd** my_db > mydb.sql
Do not open up the MySQL command line client and run that command inside of there. That client is for executing SQL; the mysqldump.exe program is completely separate and runs on its own.
> not <
You're dumping the file mysql.sql INTO mysqldump, not out of it
mysqldump -u root -p pwd** my_db > mydb.sql
Related
I want to make a backup of a db in mariaDB, I've used the following statements but any work.
mysqldump -u root -p -databases messages > dbdescargada.sql
mysqldump -u root -p messages > dbdescargada.sql
mysqldump -u root messages > clients.sql
mysqldump --user='root' --add-locks messages messages > copia.sql
mysqldump --user='root' --add-locks messages messages > copia.sql
But all showed the same error:
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 'statement' at line 1
I really need to do this backup cause I need to make important changes to the tables structures,
I'm using Xampp for Linux, Ubuntu 20.04
I know I can do it from localhost/phpmyadmin but I need also a code option
You have 2 problems:
1) You are running it from mysql CLI. mysqldump is a shell command, not a mysql command.
2) Lose the - in -> redirect to file - there is no minus before >
The parameter is --databases
Your images suggests that you run the shell command in the mysqlshell that is wrong, yoz must run it in a normal command window bash msdods...
Please check the parameters
mysqldump -u root -p --databases messages > dbdescargada.sql
I m trying to get a mysql dump of my bugtracker tool. MySQl is installed with the WAMP server and i m trying to get the dump from the mySQL console with the following command:
mysqldump -uroot -p[password] dbname>/DBBackup/dbname_18052017.sql;
but i m getting an error as there is a syntax 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 -uroot -p[password]
dbname>/DBBackup/dbname_18052017.sql;' at line 1 can some one help me
figure out this
mysqldump is a utility program. It's not a SQL statement.
Execute mysqldump from the shell prompt just like you execute the mysql command line interface program.
FOLLOWUP
By WAMP, we take that to mean you are running on Windows (not Linux). For Windows...
Start -> Run -> "cmd.exe" enter
Change directory to the location of the MySQL binaries
> cd C:\Program Files\MySQL Server 5.6\bin
This is going to be the directory that contains "mysqldump.exe". The actual name of the directory is going to depend on where MySQL was installed as part of WAMP.
Then
> mysqldump.exe -u user -pmypassword --quick dbname >C:\somedir\backup_20170518_dbname.sql
(Windows will look for an executable in the "current directory". Otherwise, it needs to be in a directory included %PATH% environment variable. Or, you can fully qualify the name of the executable.
In the Command Line I created a database with:
create database mysql;
but when i try to upload a database file with the command:
mysql -u root -p database < dbdump.sql;
i receive a syntax error and i don't understand where i'm wrong
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 root -p database < dbdump.sql' at line 1
confirm you're running the command from a shell and not from mysql.
I recall needing to be in mysql.exe directory when running such commands
remove the spaces around <. Ie, write mysql -u root -p database<dbdump.sql
I have a MySQL database which I want to duplicate using the Ubuntu Linux CLI without first having to download a MySQL file. I tried the following command:
mysql -uroot -e'mysqldump -uroot db_old | mysql -uroot backup db_new;'
But got this error:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use.
What am I doing wrong? What I'm looking for is for db_new to be created containing the same data as db_old (in other words, copy db_old and name the new database db_new, all in one command without needing to export the data to a file).
First, create the new database
mysql -uroot -pyourpasswd -e "Create database db_new;"
Then run the following (you don't need to execute "-e")
mysqldump -uroot -pyourpasswd -n db_old | mysql -uroot -pyourpasswd db_new;
From the man page:
mysqldump is also very useful for populating databases by copying data
from one MySQL server to another:
shell> mysqldump --opt db_name | mysql --host=remote_host -C db_name
The "-n" option is short for "--no-create-db"
If you don't need a password for your root connection (not recommended), then remove the "-pyourpasswd" from all statements
This is the command I used:
mysql> mysql -u root -p -h HOST sample < mysqldump.sql;
But I encountered an error as follows:
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 root -p -h HOST sample < mysqldump.sql' at line 1
Hope you can help me out?
That's the command you should give in the command line, not in MySQL itself.
Open mysql terminal or konsole and then go to the directory where mysqldump.sql file is present. try:
shell> cd /file_path/;
shell> ls -al mysqldump.sql;
It should display your file. Also you dont need to specify HOST if you are logged on to the same server.
shell> mysql -u root -p sample < mysqldump.sql;
from client you can run \. mysqldump.sql but i think first variant is preferable.