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.
Related
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.
i am executing query for importing sql dump in ubuntu
mysql -u username - p passsword databasenme < var/www/sql.sql;
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 'mysql -u
There should not be any blank space between -p and the password.
mysql -u username -p<PASSWORD HERE> databasenme < var/www/sql.sql;
UPDATE:
I assumed you weren't logged in to mysql already. If you are, you should exit from mysql console and then retry.
You can import .sql file using :
mysql -u <user> -p<password> <dbname> < mysqlfile.sql
Note: There shouldn't space between -p and <password>
Reference: http://dev.mysql.com/doc/refman/5.0/en/mysql-batch-commands.html
Time taken for importing huge files most importantly it takes more time is because default setting of mysql is "autocommit = true", you must set that off before importing your file.
First open MySQL:
mysql -u root -p
Then, You just need to do following :
mysql>use your_db
mysql>SET autocommit=0 ; source the_sql_file.sql ; COMMIT ;
You are logged in to mysql. press ctl+z to exit and try again.
don't write user's password on this line, type only flag -p , and in new line enter password:
$ mysql -u user -p database_name < your_file.sql
Enter password:
EDIT:
Check .sql file for syntax, maybe have a syntax error in the file.
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
I'm using WAMP Server in a local PC.
I'm trying to export a big database using MySQL console but its just not working. I always get a syntax error 1064
The queries I tried:
mysqldump -u USER -p DATABASE > backup.sql;
mysqldump -u USER -pPASSWORD DATABASE > backup.sql;
(of course I'm replacing USER, PASSWORD and DATABASE with real values)
I also tried some more similar queries but I'm getting the same syntax error every time.
Please help!!!!!
You should type this in your command prompt not in MySQL console.
mysqldump is an application not MySQL command.