Not connected : Access denied for user 'wwwrun'@'localhost'
JUst installed LAMP on openSUSE. They all seem to be working well individuallu.
However, after i created a database, i created a PHP file to connect to it using
> $username="username;
$password="password";
$database="username-database";
?>
i get the error:
> Not connected : Access denied for user 'wwwrun'@'localhost' (using password: NO)
I have no idea who - wwwrun is. I created the database under the default root user. I created another user and gave all access priviledges, and i still get the same error - so ive ruled out username/password problem.
Anyone know what the problem might be please?
3 Replies
See this page from the php manual:
FWIW, though, sounds like wwwrun may be the user that php is running under via your http server.
> // Opens a connection to a MySQL server
$connection = mysql_connect ("localhost", $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
But why/ how is it using that user? I didn't create it. How can i change it?
Looks like in SUSE that Apache runs as the wwwrun user, which presumably is the username that PHP tries to use for the MySQL connection if a username isn't provided.
Try putting the following before the line with mysql_connect():
error_log( "Connecting to MySQL with username: " . var_dump($username) . " , password: " . var_dump($password) . " , database: " . var_dump($database) );
and check your error log to see what you get for the variables.