#1045 - Access denied for user 'root'@'localhost' (using password: YES)

Little background: I used digital ocean to create a wordpress site.
I used the one click install they provided on their page and now my wordpress site is running.
And I followed this guide to do some preparation:

And then I followed the last step where they teach you how to install phpMyadmin GUI.
(this article):

However after installing it I cannot log into it, neither from the GUI nor from command line works.
Both of them gave me this error:

#1045 - Access denied for user ‘root’@‘localhost’ (using password: YES)

I did a simple google search and I found that I need to edit this file:
config.inc.php
And manually add in mySQL password.

But I cannot find this file on my Ubuntu server… Where can I find it and can I edit it inside terminal?
If so, how to do that ?

I key in pwd in terminal it shows me i am at root. But ls gives me nothing.
How do I edit that file then?

Thanks in advance.

Hello @zhouxiang19910319 - have you tried the credentials WordPress uses to talk to the database? The username and password are found in a file located in the same folder as wp-admin and wp-content and wp-includes, and the file is called wp-config.php. The username and password are located right up top.

hey, about that… I did not set up wordpress locally so where do I find those files ?
I am ssh into a ubuntu server…

Hey @zhouxiang19910319,

I am unsure what you are saying about " I did not set up wordpress locally". I assume from your original post that you set up WordPress using the “one-click” install on a Ubuntu server., and that you cannot log into phpmyadmin.

Assuming this is actually the case your WordPress files can be in a couple of places. They may be in the “root” folder, and if so there should be a “home” folder inside the root folder. If “home” is in there drill down through the folders until you come to the folders I outlined in my first post, ie wp-admin, wp-content, and wp-include. The file you want to examine is in the same folder as these 3 folders, and called wp-config.php.

If you cannot find the “home” folder inside the “root” folder try looking for it directly in the root of the file system, ie “/”. Just keep using the command “cd …” ( 2 dots, not 3 ) until you get to the root of the file system.

On my Digital Ocean server running Ubuntu and a nginx server my WordPress installation is at:

/home/{username}/[website name}/public/

where {username} is the name of the account you set up, and {website name} is the domain name you chose.

This may not be exact for your case ( I have observed a lot of variations between installations ) but it should point you in the correct direction.

ah… sorry I did try to do that but messed up the 1st time.
I found config.inc.php, how do I open it and edit it?

Use the nano Ubuntu builtin editor.

I think that my config.inc.php file is empty… what should I put in there?

I have no idea. Make sure you did not mis-spell the filename in nano, if you do it creates a new blank file, and it tricks you into thinking the file is empty.

I would still try to find your WordPress installation files and recover the database username and password that way.

1 Like

I knew that my username and password is correct…

the thing is my config.inc.php is empty. I double checked .

It was supposed to have something like these in it:

/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = '299.189.34.225';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '0a009ac2f35b29ebf161126ced7121e';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

Try setting the

to false just to test.

Remember you have to restart the server, and perhaps other services, to have the change take effect.

Like:
○ sudo reboot
○ sudo service nginx restart
○ service php7.1-fpm restart

1 Like

One last note about this, there very well may be more that one config.inc.php, and perhaps that is why this one is empty.

You may need to do a little more reading about the location of that file.

BTW - this file seems to be blank unless you are over riding the default configuration file for phpmyadmin.

I did a guick google and found this:

https://docs.phpmyadmin.net/en/latest/setup.html#manually-creating-the-file

1 Like

thank you I will take a break from this and get back to it tomorrow. will keep you posted!

Hi, I’m using Lubuntu so there will be some differences from Ubuntu and I dont have Wordpress. However, the location of the files on my system are: /usr/share/phpmyadmin/setup/frames/config.inc.php
/var/lib/phpmyadmin/config.inc.php
/etc/phpmyadmin/config.inc.php

You can find the files on your system by using su or sudo to gain root access, followed by the following command:
find / -name config.inc.php.

This searches all directories recursively from the root folder down.