Solved

importing large sql file to local LAMP (xampp) environment

Posted on 2011-03-04
13
1,229 Views
Last Modified: 2012-05-11
I have used Linux to import a large mysql dump file (into a new database), but am new to how the process works in a local LAMP environment using xampp, as xampp does not support SSH. I've dowloaded the large_dump_file.sql from the Linux server to my local system. I'm using Windows XP and have used xampp to setup LAMP. I am able to access the local_database via phpMyAdmin, but the dump file is too large to import using that app. I'm trying to import the file via the command prompt, but so far with no success.

At the prompt:
cd ..
cd ..
cd xampp
cd mysql
cd bin

I've found that mysqlimport is used to import .csv and .txt files, and mysql is used to import .sql files, but can't find documentation as to whether or not to use the -u -p options so I've tried many variations of the command with no luck.

Also, do I need to change any config files on my local system?

Thanks.
0
Comment
Question by:mralston2010
13 Comments
 
LVL 13

Expert Comment

by:darren-w-
Comment Utility
ho you need to cd into the mysql/bin folder and run a command similar to :

mysql -u username -p password database_name < filename.sql

example here:

http://www.velikan.net/import-sql-dump-file-to-mysql-database/
0
 
LVL 13

Expert Comment

by:darren-w-
Comment Utility
if you try logging into mysql like"mysql -u root -p" and use the password you have set to test first, before running the above command, ps you may not have a password set

so if this works the above coammand would be like

mysql -u root -p password database_name < filename.sql

if you omit the password in the command you should get prompted for it
0
 

Author Comment

by:mralston2010
Comment Utility
Thanks.

I'm able to login to mysql via
mysql -u root -p password

and then I run
db_name < filename.sql

and get 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 'db_name < beta_20110303_11.sql' at line 1

I placed the dump file in my bin directory. Should it be somewhere else?
0
 
LVL 13

Expert Comment

by:darren-w-
Comment Utility
run the command on the dos command line not within the sql command interface
0
 
LVL 7

Expert Comment

by:Vimal DM
Comment Utility
Hai,

I have an good idea,

Just take the file db file from "xampp\mysql\data"  and put accordingly in the folder that you need

1) Windows xampp\mysql\data
2) Linux lib/mysql/
0
 
LVL 34

Expert Comment

by:Beverley Portlock
Comment Utility
@vimalmaria - your suggestion is reasonable if both machines have the same language, chararcter set, underlying OS, etc, etc, but to cross from from OS to another then I would regard the binary approach as unsafe. Exporting and reimporting as Darren-w- suggests is the safest route.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:mralston2010
Comment Utility
darren-w-:

If I run the command while not in the mysql command interface, it runs through the header and usaged, but doesn't do the import.

E.g. the output after running the command:
----------
mysql  Ver 14.14 Distrib 5.5.8, for Win32 (x86)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Usage: mysql [OPTIONS] [database]
  -?, --help          Display this help and exit.
  -I, --help          Synonym for -?
  --auto-rehash       Enable automatic rehashing. One doesn't need to use
                      'rehash' to get table and field completion, but startup
                      and reconnecting may take a longer time. Disable with
                      --disable-auto-rehash.
...and more
-------------------------
0
 
LVL 13

Expert Comment

by:darren-w-
Comment Utility
Hi,

can I assume you have created the database that you are importing the sql dump file into and that the root account has full read and write permissions on the table?

Login into mysql as above, issue the command "show databases;" it will list the available databases, type "use your_database_name_here;"  and then issue the command' show tables;'  you should get a reply like "empty set.."

this will confirm that the database exists and you can gain access to it to view the tables.

Darren
0
 

Author Comment

by:mralston2010
Comment Utility
Hi Darren

The database does exist and I've already imported the tables via phpMyAdmin (390). I verified that I could access everything via the standard commands (show databases, use db, show tables).

I'll keep doing some research as well. I guessing that it is some config file that needs to be modified.

Thanks.
0
 
LVL 4

Expert Comment

by:Tomun
Comment Utility
The command line for mysql is not 'mysql -u root -p password' its 'mysql -u root -ppassword'

if there is a space after the -p then it assumes that's the name of the database you're connecting to. If you specify simply -p then it should prompt you for a password.

Can you get the command line client working now?
0
 

Author Comment

by:mralston2010
Comment Utility
Thanks to all for your input. I found the solution by submitting to serverfault.  I didn't have the max_allowed_packet size large enough. It was set at 64M and my file was 840MB.
0
 

Accepted Solution

by:
ee_auto earned 0 total points
Comment Utility
Question PAQ'd and stored in the solution database.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now