/kb

personal knowledgebase

Archive for the ‘mysql’ tag

#1064 – You have an error in your SQL syntax

without comments

When exporting and importing from and to different MySQL databases with diferent version numbers this error message might show up:

#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 ‘ENGINE=MyISAM DEFAULT CHARSET=utf8′

I got the message when exporting from a MySQL 5.x database and importing to a MySQL 4.x database. The solution came to me from the following blog post comment and is very easy. Just add the --compatible option:

mysqldump -u username -ppassword –compatible=mysql40 database_name > FILENAME.sql

Written by hgrimelid

March 4th, 2009 at 11:28 am

Posted in Server

Tagged with ,

Importing a MySQL dump file

with one comment

mysql -h SERVER -uUSER -p DATABASE < DUMPFILE

Written by hgrimelid

January 6th, 2009 at 7:58 pm

Posted in Server

Tagged with , ,

Create a new MySQL-user with all privileges

without comments

GRANT ALL PRIVILEGES ON thedatabase.* TO 'theusername'@'localhost'
	IDENTIFIED BY 'thepassword' WITH GRANT OPTION;

UPDATE 20080916: Skip the last line if the user exists.

Written by hgrimelid

May 17th, 2008 at 7:26 pm

Posted in Server

Tagged with

Backup a MySQL database with mysqldump

without comments

It’s very easy, but I always have to look it up.

mysqldump --opt -u USERNAME -p -h HOST.HOST.COM DATABASE_TABLE > DUMPFILE.sql

Written by hgrimelid

May 14th, 2008 at 6:29 pm

Posted in Server

Tagged with , , ,

Join tables in MySQL

without comments

Join three tables (shows, bands, locations) in MySQL:

select * from shows 
left join (bands, locations) ON 
(bands.id = shows.band_id and locations.id = shows.location_id);

For further information see MySQL Reference manual 12.2.7.1. JOIN Syntax.

Written by hgrimelid

April 21st, 2008 at 9:45 am

Posted in Server

Tagged with ,