I just installed and configured Apache, MySQL, PHP and phpMyAdmin on my Macbook to have a local development environment. But after I moved one of my projects to the local server, I get a strange MySQL error from one of my calls to mysql_query ():
Access denied for user '_securityagent' @ 'localhost' (using password: none)
First of all, the query I'm sending to MySQL is valid, and I even check it through phpMyAdmin with excellent result. Secondly, the error message only occurs when I have at least 4 other connections and mysql queries on the page. This mysql_query () call occurs at the end of a very long function that processes data for newly created or modified articles. This is basically what it does:
- Collect all the data from the article form (title, content, dates, etc.).
- Confirmation of collected data
- Database Connection
- Dynamically build a SQL query based on verified article data
- Send a query to the database before closing the connection
Pretty simple, I know. I didnβt recognize the username "_securityagent", so after a quick search I came across this from an article in Apple Developer Connection talking about some random error:
Mac OS X's security infrastructure addresses this issue by running its GUI code as a special user, _securityagent.
So, as Frank suggested in the comments, I put var_dump () for all the variables used in the mysql_connect () call, and every time it returns the correct values ββ(where the username is not "_securityagent", of course). So, I am wondering if anyone has any idea why the "securityagent" is trying to connect to my database, and how can I prevent this error when calling mysql_query ().