Error #1251 - Cannot log in to the MySQL server

Issues related to applications and software problems
Post Reply
Posts: 1
Joined: 2019/06/20 10:13:55

Error #1251 - Cannot log in to the MySQL server

Post by seth5728 » 2019/06/20 10:18:23

I bought a VPS today to use as my new MySQL server. I installed MySQL, Apache, PHP, and phpMyAdmin. I set up my MySQL user as "admin". I am able to log into the user on the command-line, but not in phpMyAdmin. I get the error #1251 Cannot log in to the MySQL server.

The issue is on a new Linux VPS running CentOS 6, MySQL 8.0.16, and Apache 2.2.15. I have tried everything I came across in the past 6 hours of googling. I will create a list of everything I've tried since that will be easier to read.
  • - setting bind-address to
    - putting my username and password into
    - setting the host to in
    - trying sockets over TCP (and setting the host to localhost when using sockets)
    - creating a soft-link shortcut from `/usr/share/phpmyadmin` to `/var/www/html/phpmyadmin`
    - reinstalling and running mysql_secure_installation
and a lot more things that I can't quite recall at the moment.

Code: Select all

$cfg['Servers'][$i]['host']          = ''; // MySQL hostname or IP address
$cfg['Servers'][$i]['port']          = '';          // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket']        = '';          // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type']  = 'tcp';       // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension']     = 'mysqli';    // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress']      = FALSE;       // Use compressed protocol for the MySQL connection
                                                    // (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['controluser']   = '';          // MySQL control user settings
                                                    // (this user must have read-only
$cfg['Servers'][$i]['controlpass']   = '';          // access to the "mysql/user"
                                                    // and "mysql/db" tables).
                                                    // The controluser is also
                                                    // used for all relational
                                                    // features (pmadb)
$cfg['Servers'][$i]['auth_type']     = 'cookie';    // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user']          = 'admin';     // MySQL user
$cfg['Servers'][$i]['password']      = 'areallygoodpassword';  // MySQL password (only needed

Code: Select all

<IfModule php5_module>
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php

LoadModule php5_module modules/
AddType x-httpd-php .php
AddHandler php5-script .php

Code: Select all

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8
   Order Allow,Deny
   Allow from All

Code: Select all


After trying all of this, I have had no luck and I am still getting the same error #1251 Cannot log in to the MySQL server. Any help would be greatly appreciated at this point, as I am getting desperate.

Posts: 3008
Joined: 2014/09/20 11:22:14

Re: Error #1251 - Cannot log in to the MySQL server

Post by aks » 2019/06/24 00:45:35

I'd suggest trying to login as that user from the commandline as in:

mysql -u <username> -p<password> -h
NOTE: No space between -p and the password.

MySQL may differ between (say) a user logging in as <user>@ and <user>@localhost for example.
If you can login as that user to MySQL, and you are really using the configuration parameters you've set in the PHP side of things, then the problem probably exists in the PHP/Apache side of things.
That's gotta be a better start than randomly throwing stuff in the dark, hoping you'll stumble upon something.

Post Reply

Return to “CentOS 6 - Software Support”