Solved

PERL DBI MYSQL Import .sql into MySQL using PERL DBI

Posted on 2007-03-29
3
1,000 Views
Last Modified: 2012-05-05
I am having trouble importing a .sql file (created from a MySQL export). I was using the following code on a unix box but it doesn't work on a win* box so I am thinking PERL DBI but I wasn't finding any clues.

my $imp=`mysql  --user='$db_user' --password='$db_pass' $db_name < $db_file 2>&1 `;
0
Comment
Question by:Bob-Villa
3 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 18818399
Does the command work if you run it from the command line?
Do $db_user, $db_pass $db_name and $db_file all have the correct values?
0
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 500 total points
ID: 18820576
I think the problem is with the redirection of STDERR, the  2>&1 part, it has no meaning is Windows

Try this line:
my $imp=system("mysql  --user=$db_user --password=$db_pass $db_name < $db_file");
0
 
LVL 1

Author Comment

by:Bob-Villa
ID: 18843439
Well, it seems that I had 2 problems.
1. Even though mysql is in my server's path I needed to specify the full path to mysql (C:/mysql/bin/mysql)

2. Win* did not like the ' quotes surrounding my username/password.

using teraplane's system example I was able to see the system errors print to screen and it technically was the correct answer for the question posted.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
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 …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

21 Experts available now in Live!

Get 1:1 Help Now