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.
Related
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 am unable to create mysql database dump. I have tried all the commands in the below question
https://stackoverflow.com/questions/24858436/unable-to-create-mysql-dump-in-mysql-server-5-6-19
But every time I get similar error which asks me to check manual
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 -pmysqlmysql hospital_management -r "c:\hosp.sql"' at line 1
I am trying these commands in Mysql command line and NOT on Windows command prompt. Also I am trying these commands before entering any database in mysql.
mysql> mysqldump -u root -pmysqlmysql hospital_management > hosp.sql
This was the first command I tried, which did not work
mysqldump is an executable, you should not run it in the MySQL command line.
Try the command
mysqldump -uroot -pmysqlmysql hospital_management > "C:\hosp.sql"
By reading the documentation, I assume that when using -r, the file must already exist.
I am trying to restore a mysql db using a .sql.gz file. I am using mySql console to run a command because file size is too large for phpMyAdmin. Command I am using is
gunzip C:/Vik/Gya/Source/beed_2013-04-06.sql.gz | mysql -u root -p bd
where root is the user id. There is no password for root. bd is the database to which I am trying to import. mysql is running on my local machine (Windows 8). I have a wamp setup.
This is the error I am getting:
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 'gunzip
C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql | mysql -u root
-p' at line 1.
You need -c option (output to stdout)
gunzip -c xxx.sql.gz |mysql -u root -p
While Kisoft´s answer is the correct one, I just wanted to point out that you don´t need the -c, it works just fine as it is.
this command will unzip the database dump and import it into the database at the same time.
gunzip < output.sql.gz | mysql -u <username> -p<password> <database>
If you type gunzip and you get a SQL syntax error that complaints about gunzip, you are already logged into the mysql console. The mysql console is not a general purpose shell!
You are using Windows and I suspect you haven't installed gzip in your computer (it isn't a builtin utility). It's a classical Unix tool but you can find binaries for Windows. Install it and run your original command with a couple of tweaks:
Make sure you're in Windows prompt (C:\>)
Redirect gunzip result to stdout rather than a file:
gunzip --stdout C:/Vik/Gya/Source/beed_2013-04-06.sql.gz | mysql -u root -p bd
Alternatively, you can run the dump from within MySQL promt (mysql>) if you uncompress it first (you don't need specifically command-line gzip, most GUI archivers such as 7-Zip support this format):
mysql> \. C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql
you do not need to gunzip
just:
zcat myfile.gz | mysql -uuser -ppassword mydatabase
it is faster this way
Your answer is already here
phpMyAdmin: Can't import huge database file, any suggestions?
Under php.ini file, normally located in c:\xampp\php or wampp whatever you called
post_max_size=128M
upload_max_filesize=128M
Changing value there will get you what you want.Good luck
Dont forget to restart , apache and mysql .
Try this following steps to restore db using .gz files:
1. Run command : gunzip C:/Vik/Gya/Source/beed_2013-04-06.sql.gz
This will uncompress the .gz file and will just store beed_2013-04-06.sql in the same location.
2. Type the following command to import sql data file:
mysql -u username -p bd < C:/Vik/Gya/Source/beed_2013-04-06.sql
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
this is what I use in MySQL console (WAMP) (no password, as it is local)
mysql> mysql -u root -p dbase < table.sql
or this
mysql> mysql -u root -p dbase < C:\path\to\table.sql
this is what I get:
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 dbase < table.sql' at line 1
what may cause this problem?
The command you're using is meant to be run outside of the mysql shell. If you just exit out of the mysql shell and enter the same command, it should work.
OK - step by step - since, if someone is not used to it, any omission may get that "someone" lost.
remote nix server:
connect to mysql cli (command line interface) using e.g. Putty - type in: mysql -u user -pyourpassword
now you are connected to MySQL server and you can use e.g. LOAD INFILE command etc.
"exit" gets you back to "-bash" so you can use, e.g. database importing - just type: mysql -u root -p hmvc < table.sql
local WAMP - (setup: WAMP2.2 - Apache2.2.21 - MySQL5.5.20)
case I: using Windows "command prompt"
change directory to the one, where your mysql resides within WAMP root, e.g.:
C:\wamp\bin\mysql\mysql5.5.20\bin
connect to mysql cli:
mysql -u user -pyourpassword
now you are in, so you can use e.g. LOAD INFILE command etc.
"exit" gets you back to "C:\wamp\bin\mysql\mysql5.5.20\bin>" so you can use, e.g. database importing:
mysql -u root -p hmvc < table.sql
etc.
case 2: using mysql cli directly
WAMP offers a link to it in its tray icon command collection
link is called: MySQL console
it calls mysql server diretly by invoking C:\wamp\bin\mysql\mysql5.5.20\bin\mysql.exe
you can use all MySQL commands right away, like e.g. LOAD INFILE
you cannot import/dump database using this console
if you try to exit, MySQL console will do just that - it will exit (window gets closed)
I hope it will you some time.