Ubuntu – How to change root password for thesql and phptheadmin


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.

Best Answer

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)
Related Question