Solved

PERL DBI MYSQL Import .sql into MySQL using PERL DBI

Posted on 2007-03-29
3
1,016 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
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…
Six Sigma Control Plans

724 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