Access denied error

I am attempting to run a php script to import a .csv file into a table. It is a very simple process. However, I keep getting “access denied for user.”

Here is the error:
Import Error: Access denied for user ‘username’@‘%’ (using password: YES)

This is MySQL I take it?

Yes. Sorry for not mentioning. MySQL.

Here is the script i am trying to run to import the .csv into may table.

<?php $conn = mysql_connect('mysql1.g********.com','xxxxxx','xxxxxx'); mysql_select_db('ryanwoo_map'); mysql_query("TRUNCATE TABLE ryanwoo_csvimport") or die(mysql_error()); mysql_query("LOAD DATA INFILE 'arrestlistNEW.csv' INTO TABLE ryanwoo_csvimport fields terminated by ',' ENCLOSED BY '\"' LINES terminated by '\r\n'( name ,address ,charge ,lat ,lng)") or die("Import Error: " . mysql_error()); ?>

I am not sure how the CSV file is getting to the server? I think that may be the issue here, since the csv file is remote from the SQL server, I don’t know how that command would work. I am by no means a MySQL expert so I could be wrong :wink:

the csv is located on the same server as my website.

ok, the SQL server cannot access that path then :slight_smile:

that would be the issue and ‘access denied’

I found this and it may be of use:
Import a CSV file to MySQL via phpMyAdmin | Dave's Blogs

I am trying to run an automated mysql csv import. I do not want to have manually import a csv file into my table everytime, it will make it impossible.

Is there any workaround to setting up an automatic import or import script?

Not in that manner no, since the mySQL is not local it cannot access the file.

is there a way for me to do a mysql command in a crontab?

I think u should xtbackup to import MySQL tu bep, tu bep dep, tu van kien truc.
Thanks