4

An error occurred while installing the database: │ │ ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using │ password: NO) .

Why on earth is it not prompting me for the root password during the setup of phpmyadmin? This is just baffling to me. It doesn't ask for the password, tries to log in without a password and of course gets denied. It only prompts me for a new password for the phpmyadmin user.

How can I solve this? I'm at a loss. This is a pretty fresh install of Ubuntu 16.04. I've had MySQL setup and working for a while now with no issues. I can log in via mysql -u root -p with no issues at all.

Aurelius
  • 343
  • 2
  • 15

3 Answers3

0

Coming back to this question as I believe I have found the answer. I use mariadb, and from what I gather you can only log in as -u root, even with password, when you run mysql with superuser permissions. This makes sense, as system services like mariadb are run as root. Therefore trying to access mariadb's root user from a standard user account won't work.

This has tripped me up multiple times, as mysql acts differently than mariadb in this case, and I had gotten used to the way mysql does it. If you run

mysql -u root -p and enter the correct password (using mysql, not mariadb) it will work. It seems mariadb added another layer of security, needing you to not only know the mysql root user's password, but also have superuser permissions. Therefore, you must do

sudo mysql -u root -p anytime you need to access the database as the root user. I haven't tested to see if this only applies to command-line access, or if programs running at user level would also be denied with proper credentials -- I suspect they would. This encourages the much more secure practice of creating users with limited permission scope, who can access only the databases they need access to.

So to the original point: this may have been a bug in phpmyadmin, as installing it via apt implies superuser permissions during install. Not sure what the specific issue with phpmyadmin is, but I do know why this bug happens.

Aurelius
  • 343
  • 2
  • 15
-2

Open a new tab of terminal, login to server, then run:

mysqladmin -u root -p'oldpassword' password ''

*Replace oldpassword with current root password

Then go back to tab with phpmyadmin installer. Click retry and go through the process. It will now work.

Then, go back to other tab after that finishes and run:

mysqladmin -u root -p password 'oldpassword'

When it asks for password hit enter.

*Replace oldpassword with intended root password again.

Congratulations, phpmyadmin is now installed and root is secured again.

Nemosciri
  • 1
  • 1
  • This is bad, bad practice. While it may work, you **must** warn user they would lose any security for some time stretch, and if somebody tries to access their server during that time, it would be possible to do nasty things. – Nikita Kipriyanov Jan 05 '21 at 17:50
-2

I got around this by temporarily changing the root password to blank.

 mysqladmin -u root -p'oldpassword' password ''

How to change my MySQL root password back to empty?

After running this, preferably in a separate tab of the terminal, rememeber to run the opposite to change it back:

mysqladmin -u root password 'oldpassword'
Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
jjz
  • 97
  • 2
  • This is bad, bad practice. While it may work, you **must** warn user they would lose any security for some time stretch, and if somebody tries to access their server during that time, it would be possible to do nasty things. – Nikita Kipriyanov Jan 05 '21 at 17:52
  • This is just for an offline development environment. Do you have a better solution? – jjz Feb 08 '21 at 20:15
  • This may be an offline development environment for *you*, but you're answering some other pepole question and that wasn't probably an offline development environment for them. Also somebody might encounter the same problem, find this in google and happily apply your solution exposing themselves to the risk. That's why, while this indeed solves the original problem as stated, you must warn about possible consequences. As to "how": setup and use PAM auth (so while you're root, you won't be asked for root password); use .my.cnf user config with password and tight priveleges; there are other ways. – Nikita Kipriyanov Feb 09 '21 at 05:49