Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Problem importing SQL file into phpMyAdmin

Problem importing SQL file into phpMyAdmin
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2007
Status: Offline
Reply With Quote
Aug 13, 2007, 07:49 PM
 
I just got a MacBook Pro (switched from a Windows machine) and I've mostly got it set up just like I want it. I am having a problem importing into phpMySQL, though, from a Linux machine (I am importing the MySQL data from the hosting server to develop the site locally). I never ran into problems with this on my Windows laptop but I get the following error on my Mac:

#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 'barrel_id int(11) NOT NULL auto_increment,
content text NOT NULL,
PRIMARY KE' at line 1

This is the SQL:

--
-- Table structure for table `barrels`
--
CREATE TABLE barrels(
barrel_id int( 11 ) NOT NULL AUTO_INCREMENT ,
content text NOT NULL ,
PRIMARY KEY ( barrel_id )
) TYPE = MYISAM AUTO_INCREMENT =2;

Has anyone run into this problem and know what's going on here? Fortunately, CocoaMySQL imports the SQL file fine but I'd like to figure this out. Thank you for any help!
     
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Aug 13, 2007, 07:55 PM
 
I've not used the tools in question myself so I don't know if they care about line ending characters, but if your coming from Windows, it may be worth changing all the line endings from DOS (carriage return, newline) to Unix (newline).

This is just a shot in the dark, but may be worth looking into.

Edit: CocoaMySQL may well do the line ending correction automatically (many Cocoa APIs don't care what line endings you use).
(Last edited by Brass; Aug 13, 2007 at 08:43 PM. )
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Aug 13, 2007, 08:15 PM
 
Does look like a line break issue, like Brass said. If it's not, what version of phpMyAdmin are you using?
     
Fresh-Faced Recruit
Join Date: Jun 2007
Status: Offline
Reply With Quote
Aug 13, 2007, 09:44 PM
 
Wow, thank you for the quick help! I do believe it is a line break issue. I opened the exported SQL file with Dreamweaver and saved it out (with Unix line feeds) and it worked. Kind of a pain to have to do that on an export but I'm glad to have an answer. I wonder if there are any ways to convert the line feeds on saving... I don't remember seeing any options. I am using phpMyAdmin - 2.10.3, BTW. I also tried saving out as ZIP thinking that might help, but no luck.

Thanks again!
     
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Aug 16, 2007, 08:23 AM
 
I've had really good success using an EXPORT of the table I need in one environment and NOT using the files but simply generate the SQL statements, then copy/paste into the new environment as an SQL statement. Depending on version differences you may need to adjust the table declarations to the appropriate type supported on the new environment (but if you are versioning up you should be fine).

Instead of choosing to export to a file and worry about linebreaks and DOS/OSX breaks, just let phpMyAdmin show you the SQL statements, then copy/paste them.

Unless you have HUGE tables of data this should work quite well. Then the only other issue I've had is if the character sets match properly (I've had registration marks represented in a data field get mixed up in one instance)
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Aug 16, 2007, 10:11 AM
 
bluedog:

If you have access to the MySQL binary tools, you should really look at mysqldump. Doing dumps is a far more elegant way of transporting from one server to another, and it is also much faster.
     
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Aug 19, 2007, 09:10 PM
 
While its true using mysqldump is a quick way to move your databases, the original poster didn't mention anything other than phpMyAdmin (on second reading, they said phpMySQL which I presumed to be phpMyAdmin).

Thanks for posting the additional info though. Its good to ad possible solutions into a thread for when others are searching for similar solutions.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:31 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2