I've set up mysql and phpmyadmin and chose not to set a password when installing hoping that once set up i could login with root and no password but i get the following error from phpmyadmin:

Login without a password is forbidden by configuration (see AllowNoPassword)

I have previously moved the phpmyadmin folder to /var/www/

I have tried changing the following line

$cfg['Servers'][$i]['AllowNoPassword'] = false;


$cfg['Servers'][$i]['AllowNoPassword'] = true;

but still had no success, so i am wondering is there a way i can change the root passwords for both so i can access phpmyadmin and create databases.

  • "the phpmyadmin folder" could be anything. pls state your op: mv source target , so we understand.
    – sig
    Oct 11, 2021 at 12:21

3 Answers 3


You can change the mysql root password by logging in to the database directly (mysql -h your_host -u root) then run

SET PASSWORD FOR root@localhost = PASSWORD('yourpassword');

phpmyadmin should use that password so not quite sure what you mean by "for both".

Make sure to set the new password into phpmyadmin's config.inc.php too, at line

$cfg['Servers'][$i]['password'] = 'yourpassword';
Otherwise, phpmyadmin may not work, echoing

Access denied for user 'user'@'localhost' (using password: YES)
  • 1
    Thank you, i was unsure if i had to set a password for both as i have only used WAMP in the past.
    – Jon
    Apr 4, 2012 at 6:13
  • Where can I find config.inc.php?
    – Hrvoje T
    Oct 10, 2016 at 9:18
  • 3
    Ok, I found it, but there is no line `$cfg['Servers'][$i]['password'] = 'yourpassword';
    – Hrvoje T
    Oct 10, 2016 at 9:27
  • 2
    usually the config.inc.php is in /etc/phpmyadmin/config.inc.php
    – Jostino
    Jul 7, 2017 at 13:40

It depends on your configuration. Follow the instruction below to reconfigure phpmyadmin, and reset MySQL password.

  1. Ctrl + Alt + T to launch terminal
  2. sudo dpkg-reconfigure phpmyadmin
  3. Connection method for MySQL database for phpmyadmin: unix socket
  4. Name of the database's administrative user: root
  5. Password of the database's administrative user: mysqlsamplepassword
  6. MySQL username for phpmyadmin: root
  7. MySQL database name for phpmyadmin: phpmyadmin
  8. Web server to reconfigure automatically: apache2
  9. ERROR 1045
  10. ignore
  11. sudo dpkg-reconfigure mysql-server-5.5
  12. New password for the MySQL "root" user: mysqlsamplepassword
  13. Repeat password for the MySQL "root" user: mysqlsamplepassword
  14. After all this run following command on terminal to secure your mysql server. sudo mysql_secure_installation

  15. Enter current password for root (enter for none): mysqlsamplepassword

  16. Change the root password? [Y/n] n
  17. Remove anonymous users? [Y/n] y
  18. Disallow root login remotely? [Y/n] y
  19. Remove test database and access to it? [Y/n] y
  20. Reload privilege tables now? [Y/n] y

Wish it helps!

Have a nice day!

  • 1
    MySQL password can be changed using sudo mysql_secure_installation as well. Sep 9, 2017 at 16:13
  • 1
    your wish has not come true here. The op failed. Even dpkg-reconfigure mysql-server --force -p low was of zero use.
    – sig
    Oct 11, 2021 at 12:25

I recently came across this very same issue Ubuntu 12.04. I just couldn't seem to login with root & no password. I set the AllowNoPassword setting to TRUE in the config. Later I found out that I was editing the wrong config.inc.php file to add the AllowNoPassword setting.


I believe the first is the debian local config file, which will override the usr version.

  • /etc/ does carry config while /usr/ does not. But the makers of e.g. postfixadmin ignore this valuable convention, creating confusion.
    – sig
    Oct 11, 2021 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .