getting error 1064 while importing data in phpmyadmin - mysql

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 'Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databa' at line 1
I am getting this error while importing my mysql database into phpmyadmin. What can be the reason?

This does not appear to be a valid export/dump/SQL file. If I had to guess, I'd say you redirected the output of mysqldump to a file, but used incorrect syntax when calling mysqldump, causing the error text to redirect to the file instead of the SQL code.
How big is your SQL file?
Try exporting again, being careful to monitor for errors this time. It seems to me you would have had to redirect stderr in this case, which is an odd thing to do, so you could also show us the command line statement you used to create the SQL file.

Related

"BACKUP" is not valid at this position

I'm creating how to create a Database and made a very simple code following W3Schools tutorials, however I can't seem to backup my database.
CREATE DATABASE testdb
BACKUP DATABASE testdb
TO DISK = 'E:\database';
I get this error:
"BACKUP" is not valid at this position, expecting EOF, ';'
13:19:03 CREATE DATABASE testdb BACKUP DATABASE testdb TO DISK = 'E:\'; Error Code: 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 'BACKUP DATABASE testdb TO DISK = 'E:\'' at line 2 0.000 sec
I tried to do it step by step, all together (as shown above), etc, but I always get this error.
Thank you!
Such a comand doesn't exists in mysql
see manual what us possible in MySQL like OUTFILE and mysqldump
You problably copied this form another rdms

SQL Restore backup file error

mysql -u root -paaum corpdb < /home/aaum/Videos/sp_getNOnAirDetails1.sql
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 near '' at line 4
i think so there is some problem with my sql file
Try the commands as shown below :
Login into your mysql console and run :
mysql> use corpdb;
mysql> source /home/aaum/Videos/sp_getNOnAirDetails1.sql;
If your dump file is executed perfectly then the issue is not with the file.
It's about how you are trying to import the file.
The command which you have provided is absolutely fine. But I see that probably you might be executing the command from MySQL console.
mysql> mysql -u root -paaum corpdb < /home/aaum/Videos/sp_getNOnAirDetails1.sql
Not a right way to import, try to import the file from terminal.
If you still see any errors then please post them here.
i finally bugged the problem. i forget to assign delimeter .

importing mysql dump method to find which line did it caused to fail

There are times that when you are importing a mySQL dump, it would break due to syntax, etc. Currently working on a very large database, running:
mysql -u root -p database < import.sql
will only verbose
ERROR 1064 (42000) at line 116238: 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 '' at line 389
looking at line 389
http://i.imgur.com/RX2osSD.png
won't be much help since its not the actual line the SQL is currently executing (it ignores some comments, etc.)
So, to be in general, what is the best way to debug? How to know the actual line causing the issue?
Hope somebody can help thanks!

Backwards compatible mysql dump

I am trying to port a database from mysql 5.7 to mysql 5.5.
At first, I used the following command
mysqldump -u root -p --all-databases > alldbs.sql
When I try to import the DB in mysql 5.5 I keep getting errors like
ERROR 1064 (42000) at line 572: 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 'STATS_PERSISTENT=0' at line 9
where it complains about STATS_PERSISTENT=0 statement.
Then I tried
mysqldump -u root -p --compatible=mysql40 --all-databases > alldbs.sql
but this just gives me
ERROR 1064 (42000) at line 26: 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 'TYPE=InnoDB' at line 22
where it complains about TYPE=InnoDB statement, which should be ENGINGE=InnoDB. Even with the --compatible option it still keeps the STATS_PERSISTENT statement.
Is there a way to port a mysql 5.7 database to mysql 5.5?
UPDATE
To be clear on my question, I am looking for relialble, i.e. no-hack way, to port the database. I already tried to replace TYPE with ENGINE, remove STATS_PERSISTENT etc. Something else always came up. I am not willing to jump through those hoops everytime I port the database. I am looking for a reliable way via mysqldump or a similiar tool to do the job.
If this is not possible then I will have to switch to an alternative DB.

import large MySQL Database - PHPMyAdmin error

Trying to import a very large database file.
Windows Apache PhpMyAdmin.
USE test;
source somefil.sql;
I get a syntax 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 'source somefil.sql' at line 1 "
There is no such command in mysql server as source. This command is specific to mysql own command line client, which is also named mysql, therefore it is not available in phpmyadmin.
Copy-paste the contents of the sql file into the command window of phpmyadmin and execute its contents directly from there. You may have to increase the php max execution time parameter, if the import file is truly big.
However, I would use the command line client to execute a really big sql file because phpmyadmin is not suitable for that.
to restor backup of my datebase I use command like that
from your os command promt :
mysql -u youruser -p yourdatabasename < yourfilewithfullpath.sql
Actually source command is used from command prompt so Use below steps-
Go to command prompt-
connect mysql
now use below command-
source d:/backup/somefil.sql;