0

Every time when I try to get access to phpMyAdmin, it pops up a dialog requiring username and password. I try to use root as username and leave the password blank, it doesn't work. However, when I try to use admin as username and leave the password blank, it works. But there is another issue, it shows that admin has no previlege to create a database.

So how can I get access to phpmyadmin as root? Or how can I raise privilege when I log in as admin?

The following is config.inc.php:

$cfg['Servers'][$i]['host']          = '127.0.0.1'; // 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']     = 'mysql';     // 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]['hide_db'] = 'information_schema'; 

$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']     = 'http';    // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user']          = 'root';      // MySQL user
$cfg['Servers'][$i]['password']      = '';          // MySQL password (only needed
                                                // with 'config' auth_type)
$cfg['Servers'][$i]['only_db']       = '';          // If set to a db-name, only
                                                // this db is displayed in left frame
                                                // It may also be an array of db-names, where sorting order is relevant.
$cfg['Servers'][$i]['verbose']       = '';          // Verbose name for this host - leave blank to show the hostname
Francisco
  • 10,918
  • 6
  • 34
  • 45
JqGoo
  • 85
  • 1
  • 9
  • 1
    Have you tried [setting auth_type to config](https://wiki.phpmyadmin.net/pma/Auth_types)? – Ken Y-N May 09 '16 at 00:53
  • 127.0.0.1 and localhost are different for mysql.User table. so try to use localhost than 127.0.0.1 as host – num8er May 09 '16 at 00:59

3 Answers3

0

It is not recommended or even advocated by professionals to use the root account as the login for database. You should look into GRANTs in your database, something along the lines of

GRANT SELECT, INSERT ON MyDB.* to MyDBUser@'localhost' IDENTIFIED BY 'MyDBPassword';
0

The best way to get root access privileges on a *nix system see here for instructions on recovering MySQL root accounts.

Community
  • 1
  • 1
Tom Morison
  • 564
  • 1
  • 8
  • 26
0

Try logging in from the command line client. You say you're trying to use a blank password, but I don't see the configuration directive $cfg['Servers'][$i]['AllowNoPassword'] = true; which is required for logging in with blank passwords.

Also note that, with auth_type = 'http', you do not need the $cfg['Servers'][$i]['user'] or $cfg['Servers'][$i]['password'] directives at all; they are only used with auth_type = 'config'.

Is there a chance you set a password earlier? Many package managers ask you for a password during installation. Make sure you're using the MySQL root user's password, not the system root user. This can be a bit confusing since they're both called root.

Try logging in from the command-line client; something like mysql -u root -p should be close.

In MySQL, the host field % is different from localhost so since you're connecting via the TCP/IP networking to 127.0.0.1, the account you're authenticating against is the one with either '127.0.0.1' or '%' as the host, not 'localhost' -- though you can try connecting via sockets to see if that changes things. Change the line $cfg['Servers'][$i]['connect_type'] = 'tcp'; to $cfg['Servers'][$i]['connect_type'] = 'socket'; and/or use mysql --protocol=socket -u root -p at the command line to try this different account; if that works you can fix the other user's password without resorting to brute force.

If you're still not able to connect, you'll have to reset the MySQL root password.

The reason the "admin" user account works but doesn't have any permissions is because you have the anonymous user enabled, and you're connecting as an anonymous/non-existent user. Such users are usually able to connect but not really do anything after that. You could put "kitchen" as your username and "table" as the password with similar results.

Community
  • 1
  • 1
Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43