"BACKUP" is not valid at this position - mysql

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

Related

mysqldump error while copying database from server to another

I'm trying to copy database from one server to another like this
mysqldump -u<source_db_username> -p<source_db_password> -h<source_db_ip_address> source_database_name
| mysql -u<target_db_username> -p<target_db_password> -h<aws_rds_endpoint> <aws_rds_db_name>;
But I get
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<source_db_username> -p<source_db_password>
-h<source_db_ip_address> source_database_name ' at line 1
I shouldn't use the database while copying I just have to refer the mysql location to use it and shouldn't use ';' at the end of the command it's working now.

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 .

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.

getting error 1064 while importing data in phpmyadmin

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.

Restoring mysqldump file of another version

I am restoring a mysqldump file to another server. The versions are close, so I didn't expect any problems. I get:
:/var/backups$ sudo mysql -f -u root -p dbasename < backup.sql
Enter password:
ERROR 1064 (42000) at line 542: 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 '' Current\n * President/CEO at Echoingwalls.com\n * Develope' at line 1
Other's solutions with this error message haven't been helpful. How can I detect if my back up is corrupt? I am pretty sure the versions of MySQL have been pretty close (both 5.x).
Any specific instructions on how to restore this would be appreciated.
It seems like you may have an inconsistency between how your systems are escaping single quote;
... use near '' Current\n * Presi ....
^ Note the addtional quote
Do diagnose the problem compare both tables
show create table mytable
And campare the sql modes
SELECT ##GLOBAL.sql_mode;
SELECT ##SESSION.sql_mode;
For more help find the insert statement in the dump file and post the sql.