1

I recently copied my mysql db into a new data directory and changed a few settings.

I also accidentally deleted my user directory /home/user and had all the fun of the fair recreating that.

I can now connect to mysql on the command line but cannot connect via phpMyAdmin. I get the message:

Cannot log in to the MySQL server 

I have seen this before, but not without the error code #1045 or #2002 prepended.

Would there be any logs or documentation anywhere about this message without an error code?

UPDATE

phpMyAdmin is installed on the same server and prompts the web user for a username/password in the browser login page, on submit with the correct details it returns to this login page with the error message displayed.

I have tried changing the /etc/phpMyAdmin/config.inc.php line to:

$cfg['Servers'][$i]['host'] = '127.0.0.1'; // previously 'localhost' 

I have also tried FLUSH PRIVILEGE to no avail.

11
  • 1
    I have had similar problems, more than once. Re-applying privilages directly in mysql is all that helped. I never found a good explaination. Maybe flushing privilages is also an option, that I never tried. Commented Mar 29, 2016 at 14:33
  • Where is phpMyAdmin hosted? Externally or on the same server? Commented Mar 29, 2016 at 14:33
  • How is phpMyAdmin configured. Does it ask for a user/password or does it normally just login without any human interaction Commented Mar 29, 2016 at 14:34
  • By takes a username/password. Do you mean it requests you to enter a userid/password? Commented Mar 29, 2016 at 14:40
  • Does it redirects back you to the login form Commented Mar 29, 2016 at 14:44

3 Answers 3

2

According to me the following can be the issue and the ways to resolve it

Causes:

--> path to save php_session is not set or is uncorrectly set:

--> Either php do not have sufficient rights to write to session directory or the directory does not exists.

Solution:

  1. To define the php_session directory add the below line to php.ini file:

    session.save_path="/tmp/php_session/"

  2. And give the write rights to the http server.

    Mostly, the http server run as user daemon in group daemon. For this case, the following commands will do the work for you :

    chown -R :daemon /tmp/php_session

    chmod -R g+wr /tmp/php_session

  3. restart http server.

Try it out and let me know


UPDATE

I have found this:-

In some rare cases, if your MySQL process has existed for a long time without any updates to your password, it may be storing your password in a format phpMyAdmin can't authenticate against. This will cause you to be unable to log in via phpMyAdmin, even with the correct username and password. In these cases, it is usually sufficient to change your MySQL password by another means (e.g. the command line), even if you "change" the password to the same thing.

so try just resetting your password through command line as

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but neither of these were the issue
@geeksal : Thanks so much! That was it. I have used mysql workbench to reset the password. phpMyAdmin says nothing about that issue.
1

Finally fixed it, after much confusion.

Turns out, my my.cnf file was binding the address to our server's internal network IP.

bind-address = 192.168.etc 

Previously, before moving the database (and socket location), it was also connecting with 'localhost' correctly (which uses the socket) and allowing login from phpMyAdmin.

After moving the db, the socket connection didn't work, and changing the config.inc.php line to 127.0.0.1 from localhost causes mysql to connect with TCP instead of the socket. This now caused conflict with the bind-address:

$cfg['Servers'][$i]['host'] = '127.0.0.1'; // previously 'localhost' 

Removing the bind-address restriction allowed me to login.


A better solution however, was of course to fix the socket connection.

After fussing over permissions for a while, and asking around, someone help me find a setting in mysqli.ini (the extension phpMyAdmin uses to connect to the db):

mysqli.default_socket = /new/location 

This fixed the localhost socket connection and I could reinstate my my.cnf bind-address and revert config.inc.php to use 'localhost' again.

Comments

0

in my situation, I just switch the php version from:5.6.16 to 7.0 and then it got login to nothing.

just switch it back, maybe reboot server it will support work in PHP 7.0

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.