Solved

importing large sql file to local LAMP (xampp) environment

Posted on 2011-03-04
13
1,236 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-
ID: 35036882
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-
ID: 35036924
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
ID: 35037171
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-
ID: 35037211
run the command on the dos command line not within the sql command interface
0
 
LVL 7

Expert Comment

by:Vimal DM
ID: 35037219
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
ID: 35037329
@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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:mralston2010
ID: 35037382
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-
ID: 35038122
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
ID: 35038578
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
ID: 35038903
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
ID: 35039351
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
ID: 37313446
Question PAQ'd and stored in the solution database.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

910 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

23 Experts available now in Live!

Get 1:1 Help Now