Attempting to import data to Mysql using mysqlimport

donpick
donpick used Ask the Experts™
on
Running MySql version 5.6.17 on a ML350 G5 server.  The operating system is Small Business Server 2008

Please understand I am learning Mysql .  I am not an expert.

I am trying to import a text file using mysqlimport utility.  

The command is below:
mysqlimport --user=root –password=dbxxx --fields-terminated-by=”,”   --lines-terminated-by=”\n” pivot D:\Invest-Import-Data\tblpivottxt.txt

The problem:
When I put the above command into a batch file mysql displays the error:
    “Error 1045 Access denied for user 'root @ localhost' (using password NO)

So I created a batch file which would change directory to the path where mysql exists .  The path is:
  c:\program files\Mysql\Mysql server 5.6\bin
Then I manually typed the mysqlimport command above and the data successfully  imported

Questions:
Q1.)  I have attached the batch file and the txt file and the table structure.  What changes would you make to this batch file so I don't have to manually type the mysqlimport command?

Q2.)  What must I do so the password does not have to be entered as part of the mysqlimport command?

Please give detailed answers.  I am not a mysql expert.
Useful links are always appreciated.

Thank you for your help.
tblpivottxt.txt
Mysql-Import.txt
tblpivottxt-structure.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Perhaps you do not have root access to the directory where you are saving?
Fixer of Problems
Most Valuable Expert 2014
Commented:
To use that command format, you must have two '--' in front of password, not just one.  A single '-' is for a different format.

mysqlimport --user=root --password=dbxxx --fields-terminated-by=”,”   --lines-terminated-by=”\n” pivot D:\Invest-Import-Data\tblpivottxt.txt

http://dev.mysql.com/doc/refman/5.7/en/mysqlimport.html

Author

Commented:
Hello Uma Surya:  I run the batch file in a command prompt.  When I invoke the command prompt, I explicitly invoke Administrator privileges so I feel there is no Windows permission problem.

Hello Dave Baldwin:
  Thank you for your help.  It always pays to have 2 sets of eyes to solve a problem.  You are correct, I needed 2 dashes in front of the password command.  I retyped the batch file, some how there were strange characters in the batch file itself.  Now it works.

So how about question 2, : How do I eliminate the need to have the password in the batch file?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
If it is not there, the process will stop and ask you for it before continuing.  One way or another, you have to supply the password.

Author

Commented:
Thank you for your help.  I appreciate your prompt answers.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
You're welcome, glad to help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial