Search code examples
sessioncookiesphpmyadmintokenmismatch

"Error: Token Mismatch" After adding a 2nd server to phpMyAdmin


I've been searching and trying to solve this problem for about 3 weeks. I'm stumped. Please help!

I added a second server to phpMyAdmin by adding the following lines to the end of my "config.inc.php" file in the installation directory.

$i++;
$cfg['Servers'][$i]['verbose'] = '<SERVER 2 NAME REDACTED>';
$cfg['Servers'][$i]['host'] = '<SERVER 2 ADDRESS REDACTED>.rds.amazonaws.com';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Servers'][$i]['ssl'] = false;

After I added this server, we started getting the "Error: Token Mismatch" popup randomly when running some SQL queries or performing certain actions while logged in to server #2. We never got it on the first server we had set up for several years, and I matched all the server configuration settings to those of the first server. The issue is not 100% reproducible with SQL queries, but it does seem to be 100% reproducible when I try to add users to the database via phpMyAdmin's user creation page.

Steps:

  1. log in (select server #2 in the "Server Choice" drop-down menu)
  2. click "users" tab at top of page
  3. click "add user" link
  4. fill out the required fields and click "go"

At this point I always get the "Error: Token Mismatch" popup.

Things I've tried so far:

  • clear cache / cookies (I do this every time I change settings)
  • use different browser (tried Chrome, Firefox, and Safari)
  • change ";session.save_path" variable to “/tmp” in php.ini file
  • Do "chmod 1733" on the sessions save directory
  • Made sure there is free space available (19GB free)

After all this, we still get the error.

Software:

PHP: 5.3.29
Apache: 2.2.23 (Amazon)
SQL type: 10.1.23-MariaDB
Database client version: libmysql - 5.5.24
PHP extension: mysqli
phpMyAdmin: 4.2.2

Hardware:

phpMyadmin server hardware: Amazon EC2 m3.large
SQL database server hardware: db.m4.2xlarge

Any suggestions for places to look or things to try are greatly appreciated.


Solution

  • One thing that caught my eye is that you mention the ;session.save_path variable; the semicolon in front of it is a comment so for the directive to be recognized you'll have to remove the semicolon. Check the output of phpinfo.php to verify that the change was successful.

    Other than that, it's tough to guess. You're using an old PHP and old phpMyAdmin version, so I'm not saying an upgrade will or won't fix the problem, but you really should upgrade.

    One workaround would be to have two phpMyAdmin installations; you can have phpMyAdmin in two different folders, with each one pointing to a different MySQL server. It sounds like it was working fine with one server so if you do it this way, each instance will only have one server and hopefully you won't have the problem.