Restoring mysqldump file of another version - mysql

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.

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 .

Dump file error while trying to switch to import to a MySQL

I have a dump file name mydata.dump.sql. Currently using a console of my MYSQL database. To use my data I have tried the source command:
source mydata.dump.sql
I am however 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 to use near 'TRANSACTION' at line 7
Query OK, 0 rows affected (0.00 sec)
Not sure what' s wrong with that syntax but the dump file was generated by phpmyadmin, so I guessed it was legit.
Here an excerpt from the dump file that shows line 7 :
----
-- phpLiteAdmin database dump (http://www.phpliteadmin.org/)
-- phpLiteAdmin version: 1.9.7-dev
-- Exported: 10:39pm on May 20, 2017 (UTC)
-- database file: /home/ubuntu/workspace/finale.db
----
BEGIN TRANSACTION;
COMMIT;
In command line you can use:
mysql -u your_username -p database_name < mydata.dump.sql
If you are on windows put full path
USE your db_name;
SOURCE D:/yourfolder/mydata.dump.sql;
Try to replace the name mydata.dump.sql to mydata_dump.sql
Some times also for me phpmyadmin got strange errors.
Many people recommend to use mysqldump to export and then mysql ... to import

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.

Moving from mysql 3.3 to mysql 5.5

I need to move my website with a mysql database on an old server with MySQL 3.23 to a new server with mysql 5.5.20
I have made a mysqldump with gzip and uploaded it to the new server. With gunzip file.sql.gz | mysql -uusername -ppasword dbname I tried to get it working. But I got an error. The error is
ERROR 1064 (42000) at line 4: 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 '-----
CREATE TABLE lite_' at line 1
What should I do to solve this?
For this specific error, remove the -- comment lines in your sql.
You can use any of the following:
sed -i '/^--/d' dumpfile.sql
awk '!/^--/' dumpfile.sql > filteredfile.sql
grep -v '^--' dumpfile.sql > filteredfile.sql
You might also ran into type errors for myisam.
mysql error 'TYPE=MyISAM'
Watch out for your type encodings.
you could remove all non-ASCII characters from your file
perl -plne 's/[^[:ascii:]]//g' dumpfile.sql
Special characters get lost in MySQL export/import
other notes on 3 to 5 conversion.
http://hisdeedsaredust.com/2009/02/mysql-version-3-to-version-5/
my other notes on mysql are available here:
http://dave.thehorners.com/tech-talk/random-tech/325-mysql
IMHO, mysqlimport should have been written to support output from prior versions.