Solved

PERL DBI MYSQL Import .sql into MySQL using PERL DBI

Posted on 2007-03-29
3
1,008 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…

860 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