I'm using Ubuntu desktop 16.04 (upgraded from 15.10).
I had installed phpmyadmin from by apt-get install phpmyadmin
. It works if I go to localhost/phpmyadmin
but I cannot log into it as root.
I have searched a lot for it. I have found many sources in which they suggest to alter /etc/phpmyadmin/config.inc.php
and replace the user and password with 'root' and '' (empty for password). But my config.inc.php
is different from theirs. For example in my file, there is no line for user and password and it seems it gets it automatically from another file which is /etc/phpmyadmin/config-db.php
. Despite this, I have changed the user and password in that file, but now I get this error:
#1698 - Access denied for user 'root'@'localhost'
What I should do?
Phpmyadmin Version: 4.5.4.1deb2ubuntu1
mysql Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using EditLine wrapper
Best Answer
MySQL 5.7 changed the secure model: now MySQL
root
login requires asudo
.I.e., phpMyAdmin will be not able to use
root
credentials.The simplest, safest and permanent solution will be create a new user and grant required privileges.
1. Connect to mysql
2. Create a real password
In the below steps I'll use
<please_replace_this>
as a sample password. PLEASE, REPLACE IT BY YOUR PASSWORD! DON'T USE<please_replace_this>
AS PASSWORD!3. Create a user for phpMyAdmin
Run the following commands (replacing
<please_replace_this>
by the desired password):If your phpMyAdmin is connecting to localhost, this should be enough.
4. Optional and unsafe: allow remote connections
Remember: allow a remote user to have all privileges is a security concern and this is not required in most of cases.
With this in mind, if you want this user to have the same privileges during remote connections, additionally run (replacing
<please_replace_this>
by the password used in Step #2):5. Update phpMyAdmin
Using
sudo
, edit/etc/dbconfig-common/phpmyadmin.conf
file updating user/password values in the following sections (replacing<please_replace_this>
by the password used in Step #2):