Solved

PERL DBI MYSQL Import .sql into MySQL using PERL DBI

Posted on 2007-03-29
3
995 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

12 Experts available now in Live!

Get 1:1 Help Now