Simply auto login to your Adminer

Simply auto login to your Adminer

On my local test environment, I sometimes use Adminer. Adminer is a tiny PHPMyAdmin like database administration tool that comes in one single file. So I can simply drop this file into my Docker setups for example to have a nice visual administration tool for my databases.

For some projects, I wanted to skip the Adminer login. Because I have to switch Docker containers often and don't want to log in again and again. Adminer is written in PHP. So it is easy to send the required Login information inside the $_POST variable to Adminer.

Just create a new file called adminer.php. Inside this file, you can now populate your login credentials if no other action was set. Adminer uses query strings to control its actions. You can simply check if those actions are empty and then login. Then the script will include the original Adminer file.

Simply use this adminer.php script to auto login to your adminer.

if(!count($_GET)) {
  $_POST['auth'] = [
    'server' => 'my_database_host',
    'username' => 'my_user_name',
    'password' => 'my_super_secret_password',
    'driver' => 'server',
    'db'    => 'my_database_name'
  ];
}

include "../adminer-4.8.1.php";

Title image: https://pixabay.com/de/photos/getriebe-zahnräder-maschine-1236578/