can't login in phpmyadmin and mysql after fresh installation of lamp server and phpmyadmin on ubuntu 12.04 LTS

2

I am trying to search a solution for this problem, but didn't find a solution. I am getting an error while login in phpmyadmin

#1045 Cannot log in to the MySQL server

Connection for controluser as defined in your configuration failed.

I am trying to configure config-db.php and config.inc.php files reside in /etc/phpmyadmin/ directory. There i am changing $dbname and $dbpass in config-db.php as my root user and password but still can't login. After google, i get some clue and uncommented a line in config.inc.php:

/* Uncomment the following to enable logging in to passwordless accounts,
     * after taking note of the associated security risks. */
    $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

These things are so ridiculous, follow articles like Lamp server installation shows step by step things and i do the same thing, but i get this error thrice times. Even i can't login in mysql through shell. Please help me to sort out this problem and know the actual reason why this happen when i am enter password twice time while installing mysql.

Shashank

Posted 2012-07-09T17:45:07.690

Reputation: 33

i am redirected from stackoverflow to ask this question on superuser – Shashank – 2012-07-09T17:45:56.597

With what account are you trying to log in? Can you log in with your root account? – Rhyuk – 2012-07-09T17:52:54.343

@Rhyuk: yes i am using my root account while setup during lamp server installation – Shashank – 2012-07-09T17:55:06.727

Have you tried resetting your MySQL password? – Rhyuk – 2012-07-09T17:57:44.117

i am using only root account on my server – Shashank – 2012-07-09T18:03:34.780

@Rhyuk: Through this article http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix, i'll try but it is not worthy for me, not working on ubuntu 12.04

– Shashank – 2012-07-09T18:09:33.557

Answers

1

Try changing your MySQL password:

To reset your mysqld password just follow these instructions :

  1. Start the mysql client process using this command

    mysql -u root

  2. From the mysql prompt execute this command to be able to change any password

    FLUSH PRIVILEGES;

  3. Then reset/update your password

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

  4. Once have received a message indicating a successful query (one or more rows affected), flush privileges:

    FLUSH PRIVILEGES;

  5. Then stop the mysqld process and relaunch it with the classical way:

    sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start

Source: https://help.ubuntu.com/community/MysqlPasswordReset

UPDATE:

Lets try updating your current password. Do this:

$ pkill mysql
$ sudo mysqld --skip-grant-privileges
$ mysql

At this point you get the mysql command shell. You will need to update the root password and flush the table when you reset the password.

mysql> set UPDATE mysql.user SET Password=PASSWORD('YOUR_NEW_PASSWORD') WHERE User='root';
mysql> FLUSH PRIVILEGES;

Now that you’ve flushed your passwords, just restart your mysql daemon.

$ sudo pkill mysqld
$ sudo /etc/init.d/mysqld start
$ mysql -u root -p
Enter Password: YOUR_NEW_PASSWORD
mysql>

Rhyuk

Posted 2012-07-09T17:45:07.690

Reputation: 605

I know the Source, but from shell i get the error after type mysql -u root: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) – Shashank – 2012-07-09T18:19:50.453

now get this error after doing mysql -u root: ERROR 1040 (HY000): Too many connections – Shashank – 2012-07-09T18:26:24.177

Updated the answer. – Rhyuk – 2012-07-09T18:34:53.087

pkill mysql sudo mysqld --skip-grant-privileges, after these steps, mysql command gives ERROR 1040 (HY000): Too many connections – Shashank – 2012-07-09T18:58:46.570

If you are reaching the max connection limit go to /etc/my.cnf and under the [mysqld] section add max_connections = 500 and restart MySQL.Then try to update your password again. – Rhyuk – 2012-07-09T19:12:49.550

On terminal , mysql running fine. But on phpmyadmin it shows same problem : Connection for controluser as defined in your configuration failed and #1040 Cannot log in to the MySQL server. As i increase max connection and revoke all users who have super privileges but not equal to root@localhost – Shashank – 2012-07-10T07:31:23.460

Cool, you can now login through terminal. Now you need to reset your myphpadmin password: http://en.kioskea.net/faq/673-phpmyadmin-access-denied-for-user-root-localhost

– Rhyuk – 2012-07-10T11:56:58.460

1

Try password "mysql". Your mysql root and system login root passwords are not synchronized, you have to set each individually. Make sure you change the mysql root login!

SilverbackNet

Posted 2012-07-09T17:45:07.690

Reputation: 962

i get this error ERROR 1040 (HY000): Too many connections after try password mysql and mine, but didnt work – Shashank – 2012-07-09T18:41:00.990

Try resetting mysql with service mysql restart. Since default password didn't work, it sound like you'll have to skip-grant-privs as below. – SilverbackNet – 2012-07-09T18:44:49.503