UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 13th April 2005, 02:23 PM   #1 (permalink)
Jus
Senior Member
 
Join Date: Mar 2003
Location: Dublin, Ireland
Posts: 516
Having Trouble Backing Up / Restoring DB

Currentley trying to take a backup of a database and restore it to a new database to allow me to use it for a dev version of one of my sites, but am having a few problems.

The backup of the current database has no problems executing via SSH, and I don't get any errors at all and it seems fine, but when I seem to try to restore it to a new DB, I get this.

ERROR 1064 at line 11: 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 'from varchar(255) NOT NULL default '', fromemail varchar(255)

But the database itself that I took the backup of is running fine on a live site so it's not anything serious, but I simply can't restore the DB no matter how hard I try.

I've tried the repair function in phpmyadmin as well to see if it makes any difference, but unfortunatley it does not seem to make the slightest bit at all.

Is there any other way I can copy this database that will avoid this error? Or anybody got an idea on how to fix it?
Jus is offline   Reply With Quote
Old 13th April 2005, 03:44 PM   #2 (permalink)
DigiAl
Senior Member
 
DigiAl's Avatar
 
Join Date: Aug 2004
Location: Brighton
Posts: 133
Don't know if it matters, but have you tried exporting the DB from phpmyadmin?
__________________
Vibrant Solutions : Vibrant-Solutions.Net (new site comming soon)
Complete Website Design, Development and Hosting Solutions
Brighton UK

Hoping the best of my past is the worst of my future

Everyday is a school day!
DigiAl is offline   Reply With Quote
Old 13th April 2005, 03:47 PM   #3 (permalink)
gossi
Registered User
 
Join Date: Feb 2004
Posts: 1,205
Could you paste lines 10-13 from the exported file, Jus (minus any confidential info)?
gossi is offline   Reply With Quote
Old 13th April 2005, 04:07 PM   #4 (permalink)
Jus
Senior Member
 
Join Date: Mar 2003
Location: Dublin, Ireland
Posts: 516
Is there a way I can do that without download the whole database, as it's rather big...
Jus is offline   Reply With Quote
Old 13th April 2005, 04:16 PM   #5 (permalink)
gossi
Registered User
 
Join Date: Feb 2004
Posts: 1,205
If you SSH in and run 'more DBNAME.db' it'll bring it up on screen.
gossi is offline   Reply With Quote
Old 13th April 2005, 04:22 PM   #6 (permalink)
Jus
Senior Member
 
Join Date: Mar 2003
Location: Dublin, Ireland
Posts: 516
Quote:
-- MySQL dump 9.10
--
-- Host: localhost Database: xxxxx
-- ------------------------------------------------------
-- Server version 4.0.18-Max

--
-- Table structure for table `ListMess_email_messages`
--

CREATE TABLE ListMess_email_messages (
message_id int(11) NOT NULL auto_increment,
template_id int(11) NOT NULL default '0',
date bigint(64) NOT NULL default '0',
title varchar(255) NOT NULL default '',
from varchar(255) NOT NULL default '',
fromemail varchar(255) NOT NULL default '',
replyemail varchar(255) NOT NULL default '',
erroremail varchar(255) NOT NULL default '',
priority int(1) NOT NULL default '0',
subject varchar(255) NOT NULL default '',
text longtext NOT NULL
See anything? I think I know which tables are causing the problems, is there any way I can drop selected ones from the exported .sql file using SSH then reimport it?
Jus is offline   Reply With Quote
Old 13th April 2005, 06:07 PM   #7 (permalink)
simbart
Registered User
 
Join Date: May 2004
Posts: 56
i was having the same problem backing up and restoring a mambo database. adding a -Q option to mysqldump fixed the problem. i.e:

mysqldump --add-drop-table -Q -uUSERNAME -pPASSWORD DBNAME > backup.sql

this adds back quotes around around field names. The restore then went without a hitch.
simbart is offline   Reply With Quote
Old 13th April 2005, 06:17 PM   #8 (permalink)
Jus
Senior Member
 
Join Date: Mar 2003
Location: Dublin, Ireland
Posts: 516
Tried that, still same problem
Jus is offline   Reply With Quote
Old 13th April 2005, 09:49 PM   #9 (permalink)
void
Senior Member
 
Join Date: May 2003
Posts: 134
Quote:
Originally Posted by Jus
Tried that, still same problem
did you check new sql file?
can you see if 'drop table' is added ? and if names within quotes now?


`date`
`from`
`text`

(all 3 belong to reserved mysql words)

Last edited by void : 13th April 2005 at 09:53 PM.
void is offline   Reply With Quote
Old 14th April 2005, 11:16 AM   #10 (permalink)
Jus
Senior Member
 
Join Date: Mar 2003
Location: Dublin, Ireland
Posts: 516
But won't that drop tables from the live database when doing a backup, I don't want to do that, i just want to make an exact replica of the current DB into another DB without losing anything.
Jus is offline   Reply With Quote
Old 14th April 2005, 11:27 AM   #11 (permalink)
gossi
Registered User
 
Join Date: Feb 2004
Posts: 1,205
I have to admit, I'm not quite sure on this one myself. It does appear 'date' and such are reserved words and need quotes around them.
gossi is offline   Reply With Quote
Old 14th April 2005, 11:30 AM   #12 (permalink)
Jus
Senior Member
 
Join Date: Mar 2003
Location: Dublin, Ireland
Posts: 516
I've done the command, just without the drop bit and it makes no difference, I'm very reluctant to take any risks as the backup I want to take from a database is from a very important live database, I can't risk screwing it up.
Jus is offline   Reply With Quote
Old 14th April 2005, 12:06 PM   #13 (permalink)
simbart
Registered User
 
Join Date: May 2004
Posts: 56
the drop bit, just adds a drop table command for each table to the script. So if you restored to a database that already had the tables it would drop them before, recreating them. It won't affect the live database as long you don't restore to that database. (but you don't need to use it if your restoring to a new/clean database)

are you getting the error in exactly the same place with the quotes version of the file? the problem should be that you have mysql reserved words as column names, but the quotes should have fixed that

the db that your restroing to is this on a uh server or else where.

Last edited by simbart : 14th April 2005 at 12:16 PM.
simbart is offline   Reply With Quote
Old 14th April 2005, 01:33 PM   #14 (permalink)
Andy
Senior Member
 
Join Date: Aug 2003
Location: Westgate-on-Sea, Kent, ENGLAND
Posts: 2,228
When this sort of problem occurs it usually relates to the data not being quoted correctly in the backup file.

If your using mysqldump to do the backups use the "--quote-names" option (See http://dev.mysql.com/doc/mysql/en/mysqldump.html ) . If your using phpmyadmin i think it offers a similar option. I vaguely remember having come across this problem myself when restoring a database to the test mysql server on my pc.

Andy
Andy is offline   Reply With Quote
Old 15th April 2005, 03:36 PM   #15 (permalink)
Jus
Senior Member
 
Join Date: Mar 2003
Location: Dublin, Ireland
Posts: 516
"are you getting the error in exactly the same place with the quotes version of the file?"

Yep, Afraid so, any more ideas, I tried what Andy said, still same problem, not looking good, I may just download the almost 100MB database then trim the tables out that are causing the problem from the dump from phpmyadmin then upload it then SSH.

It's long and tedious but it'll work.
Jus is offline   Reply With Quote
Old 18th January 2010, 04:53 PM   #16 (permalink)
TygerTyger
Lumberjack and OK
 
Join Date: Aug 2004
Posts: 935
I'm having similar trouble.

Code:
-bash: /var/www/html/mydb.sql: line 28: syntax error near unexpected token `('
-bash: /var/www/html/mydb.sql: line 28: `CREATE TABLE `mytable` ('
The database was exported from phpMyAdmin with backquotes enabled and I'm using SSH to restore it. The file is 350Mb, I can't read it much less edit it myself. Does anyone know what has caused this and whether I can do anything to fix the restoration?
TygerTyger is offline   Reply With Quote
Old 18th January 2010, 09:25 PM   #17 (permalink)
mark.willis
Developer
 
Join Date: Oct 2008
Location: poole, dorset
Posts: 194
Send a message via Skype™ to mark.willis
the ` will be getting executed in the bash terminal ... how are you running the command?
__________________
My PHP and MySQL Blog
mark.willis is offline   Reply With Quote
Old 18th January 2010, 09:42 PM   #18 (permalink)
TygerTyger
Lumberjack and OK
 
Join Date: Aug 2004
Posts: 935
Quite possibly, I have no idea how to use SSH. Uploaded the db to root, then something like:

Code:
mysql -u username -p password example_com_db
\. /var/www/html/mydb.sql
I'm not getting anywhere on Google finding a way to escape backticks within a file without editing the file itself.

Last edited by TygerTyger : 19th January 2010 at 12:50 PM.
TygerTyger is offline   Reply With Quote
Old 19th January 2010, 02:14 PM   #19 (permalink)
Lost_Password
Registered User *****
 
Join Date: Feb 2006
Posts: 76
If your testing website is on the same server as the original website, you can run both sites on the same database without moving anything anywhere.

If that's not what you want but the set up is the same, you could duplicate the tables you're working on with slightly different names e.g. events might become events_test etc.

If that's still no good, you can put together your own php script which outputs the contents of the database to screen. You'd do this in such a way that it creates its own SQL INSERT statements. I have had to resort to this method in the past, it's a last resort but works a treat.

D.
__________________
Incongruent Juxtaposition (TM)
Lost_Password is offline   Reply With Quote
Old 19th January 2010, 03:50 PM   #20 (permalink)
mark.willis
Developer
 
Join Date: Oct 2008
Location: poole, dorset
Posts: 194
Send a message via Skype™ to mark.willis
try this...
Code:
mysql -u username -pPassword example_com_db < /var/www/html/mydb.sql
What you are doing is telling bash to execute the sql file instead of sending it to the mysql client
__________________
My PHP and MySQL Blog
mark.willis is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 02:32 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  SEO by vBSEO 3.0.0
Copyright © 1998-2009 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309