Not connected : Access denied for user 'wwwrun'@'localhost'

Hi,

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

Those are just vars (and it looks like the one for host is missing); what are you actually passing to mysql_connect, or whatever db package you're using?

See this page from the php manual: http://us.php.net/mysql_connect

FWIW, though, sounds like wwwrun may be the user that php is running under via your http server.

Passing this?

> // 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?

In the example text in your first post, you are missing the double-quote mark at the end of your username. If your PHP script is the same way, this would likely cause it to fail.

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.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct