Urgent! Help! #1045 Access denied for user 'root@localhost'

Urgent! Help! #1045 Access denied for user 'root@localhost'

by Norbert Berger -
Number of replies: 9

I get an error message when I try to access my site and admin. I checked config.php in www directory and config.inc.php in phpmyadmin directory. No joy

Tried to add a password in phpmyadmin and now I am locked out. Reading mysql documentation and following instructions keeps telling me can't connect to database.

Average of ratings: -
In reply to Norbert Berger

Re: Urgent! Help! #1045 Access denied for user 'root@localhost'

by Tim Allen -
Hi Norbert, smile

I have had that error sometimes too - "[root@tim ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)." surprise For me it was a password problem. If I was logged into the system as root I had to supply a password like so:

[root@tim ~]# mysql -p
Enter password: (invisible)

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 85 to server version: 4.1.7-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.



This password was the mysql root user, not necessarily the user of the moodle database defined in the moodle config.php (they can and probably should be different).

Alternatively you can login as aother user which has no password, or log in with a different username and its password like so: "#mysql -u anotherusername -p"

Where did this occur for you - on the command line like my example above?

Tim.

In reply to Tim Allen

Re: Urgent! Help! #1045 Access denied for user 'root@localhost'

by Norbert Berger -

Hi Tim

Thanks for your suggestions.

Any access to the site via a browser shows that error message. So I can't go into phpmyadmin or anything.

As a stopgap, I have plugged the whole by relaunching the site on a different computer, switched IP addresses and reinstalled EasyPhP etc. Then installed backup of Moodle files. I must have messed up the privileges in PHPmyadmin and lost the root completely. I had set up another user with all the privileges and can still log into mysql and mysqladmin, but tring to restore user root@localhost using command line prompts didn't work.

Big mess, really.

What I still haven't sussed out is how to secure the root and still be able to access database admin via web access. Perhaps I am just too new to Mysql and PHP. Meant to say too thick for it.

Thanks for your efforts

Norbert

In reply to Norbert Berger

Re: Urgent! Help! #1045 Access denied for user 'root@localhost'

by Tim Allen -
Hi Norbert,

Any access to the site via a browser shows that error message. So I can't go into phpmyadmin or anything.

That suggest that the password you supplied in moodle's config.php is wrong (it doesn't match that for the moodle database).  But it sounds like you may not be sure what the password is now...sad  If you know the password, then make sure it is correct in config.php.

I had set up another user with all the privileges and can still log into mysql and mysqladmin, but tring to restore user root@localhost using command line prompts didn't work.

If you can still access your mysql database using another database username that has broad privileges, then you should be able to add a new username and password and then put the same in the moodle config.php.  For security reasons, you shouldn't use the root password for web accessible software - create a new one instead.

What I still haven't sussed out is how to secure the root and still be able to access database admin via web access.

If you are connecting using the moodle db package, you don't need to do anything.  Just login as moodle admin and then you can access the moodle database.

If you are connecting directly via phpMyAdmin, then I think the following line in phpMyAdmin/config.inc.php has something to do with it:  $cfg['Servers'][$i]['auth_type']     = 'config';    // Authentication method (config, http or cookie based)?

However I just used apache authentication in httpd.conf (or use a .htaccess file if you don't have access to that file).  If you need more info about this, please ask!  smile

Perhaps I am just too new to Mysql and PHP. Meant to say too thick for it.

Not thick!  We are all learning - myself included! cool 

Tim.
In reply to Tim Allen

Re: Urgent! Help! #1045 Access denied for user 'root@localhost'

by Norbert Berger -
Hi Tim

Many thanks for the encouragement. Will go back to trying your advice asap.

Have a nice weekend

Norbert
In reply to Norbert Berger

Sorted

by Norbert Berger -

Hi Tim

Thanks again for your advice. Everything is back to normal.

As I installed a new copy of EasyPHP into a new directory, I had full access to MySQL. I then stopped the server, copied the moodles database files and www content across to the new server, restarted and had everything back in opreation. As I do not use .htaccess, I now uderstand the server is not exposed to any security risks any more.

Hope this settles it.  Thanks again for your efforts

Norbert

In reply to Norbert Berger

Re: Sorted

by Marcus Schubert -
Hi,

just if someone is interested why this happened: If you use myphpadmin to set a password for MySQL root then the password is not saved. Mysql only knows, that there has to be a password - which indeed does not exist.

To fix this move to ...\EasyPHP1-7\phpmyadmin\ and open the file config.inc.php. When u look at the line
$cfg['Servers'][$i]['password'] = '';
you notice that phpmyadmin didn't save the password. So change it to:
$cfg['Servers'][$i]['password'] = 'your_password';

I guess im a little late with my suggestion winken

In reply to Norbert Berger

Sorted: How to set up SMTP for moodle

by steven toh -
hi Nobert,
I have got problems setting up SMTP for moodle. I received the following error when I try to reset my password.

password.jpg

Know what is my problem and how I can go about solving it?
steve