Moving from mysql 3.3 to mysql 5.5 - mysql

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.

Related

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.

MySQL dump compatibility issue (from 4.0.26 into 5.5.41)

I am trying to transfer data from MySQL 4.0.26 into MySQL 5.5.41-0ubuntu0.12.04.1.
I am making a dump from MySQL 5.5 server via mysqldump it works but when I'm trying to restore it there a problem occures:
ERROR 1064 (42000) at line 20: 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=MyISAM' at line 4
Is there some way how to create compatible dump for MySQL 5.5. from MySQL 4.0?
This should work
mysqldump ... | sed 's/TYPE=/ENGINE=/g' | > dump_file
(...and be enough. In the link Jens posted, there's another substitute for timestamp(14), but MySQL does this automatically, if I'm not mistaken.)

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.

Unable to create mysql database dump

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.

Restoring dump file after MySQL server migration from 5.1.51 to 5.5.10 throws error 1064

On a Windows 7 machine running MySQL server 5.1.51 (both 64bit), before migrating to 5.5.10, I made a backup of my entire database using MySQL Administrator. After installing 5.5.10, I tried to restore the dump file but it throws one 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 'TYPE = MyISAM DEFAULT CHARSET latin1 COLLATE latin1_german1_ci ; SELECT co_n' at line 9"
I tried restore through several MySQL applications (Workbench, SQLYog) and the command line, but all throw the same error. It also throws several warnings that are however not displayed.
Two questions:
Of course, can you help me resolve this issue? Do I have to edit the sql dump file in some way? That's cumbersome though, since it's over 3GB. I thought I had followed all the steps with respect to upgrading mentioned in the MySQL documentation, so now I am a bit frustrated and scared of data loss.
When restoring from the command line, how can I make mysql.exe log all warnings and errors to a text file?
OBSERVATION #1
MySQL provides upgrade scripts when migrating data from a previous major release. I usually do not use them. Here is what I do whenever I migrate from one major release to another:
mysqldump all databases except the mysql schema. The mysql schema from major release to major release is different.
Start with a fresh install of MySQL 5.5.10
Load all databases from the mysqldumps (except mysql) in MySQL 5.5.10
Now what about the mysql schema? You can dump it in a very special way.
This is what I do for Linux to dump the mysql schema from MySQL 5.1.51:
mysql -h... -u... -p... --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''#''',host,''';') FROM mysql.user WHERE user<>''" | mysql -h... -u... -p... --skip-column-names -A | sed 's/$/;/g' > MySQLGrants51.sql
This will produce all the SQL GRANT commands to recreate the users and permissions.
Since you are using Windows, you can do this:
mysql -h... -u... -p... --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''#''',host,''';') FROM mysql.user WHERE user<>''" | mysql -h... -u... -p... --skip-column-names -A > C:\MySQLGrants51.sql
You would have to edit C:\MySQLGrants51.sql in notepad so that every line the file ends with a semicolon(;)
Now go into MySQL 5.5.10's client and run
source C:\MySQLGrants51.sql
OBSERVATION #2
"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 'TYPE = MyISAM DEFAULT CHARSET latin1 COLLATE latin1_german1_ci ;
This error message has 'TYPE = MyISAM'. Shouldn't that read 'ENGINE = MyISAM' ?
What you need to do, is repeat the dump, using the "mysqldump" tool. This is the only tool which is capable of making non-useless dumps. Other (particularly GUI) tools TRY, but they fail, because they aren't sufficiently well-tested, particularly in this kind of scenario.
Bin your dump, and make a new one using mysqldump. Use the version of mysqldump from 5.5, for preference.