-1

I have a class and a db class all works fine with in the browser. But when i add the same DB class to another file that i then run from the terminal i et the following error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user '????@localhost' (using password: YES)'

The local test server is on a windows 7 machine running php, apache and mysql. I am doing the test via my mac and terminal.

DO i need to set the local server up further etc or am i missing any thing.

Simon Davies
  • 3,668
  • 9
  • 41
  • 69
  • 2
    You first need to understand that this error is not triggered by PHP or PDO. It comes from the MySQL Server and it's in fact quite self-explanatory. If you suspect there's an error in your code you should have posted the relevant part of it. – Álvaro González Jan 17 '14 at 12:29
  • there is no error it works perfectly when run through a browser but when run through the command line thats the error i get, so the user details are correct, same code for both. – Simon Davies Jan 17 '14 at 12:35
  • I won't say it's impossible but it's extremely unlikely that "access denied" kind of messages are triggered by anything different that incorrect credentials or missing privileges, if that's what you're asking. – Álvaro González Jan 17 '14 at 12:45
  • grant proper rights for user in DB. – Robert Jan 17 '14 at 12:51
  • what right sother than all would i need if accessing from CLI. The same user details the same class but through cli causes this. Well might have to continue and try and solve it hopefully. ta – Simon Davies Jan 17 '14 at 12:54

1 Answers1

1
The local test server is on a windows 7 machine running php, apache and mysql. I am doing the test via my mac and terminal.

Probably you are running cli files from the Mac. You need to add 'mac' address in mysql allowed hosts in windows

see Mysql adding user for remote access

Community
  • 1
  • 1
po_taka
  • 1,816
  • 17
  • 27
  • Thanks for the push, i simply had to change my host name : localhost to the ip of the local windows server: 192.168.1.73 etc, i needed to connect to. You started me to think and sort it. – Simon Davies Jan 17 '14 at 15:14