osteel's blog Web development resources

Database management with Adminer (and how to install on Homestead)

Been here before?

You can also subscribe to the RSS or Atom feed, or follow me on Twitter.

For quite some time now I have been prefering accessing databases from the CLI, but sometimes it can feel overkill when wanting to quickly check or update something, say.

In this kind of case I usually look to PHPMyAdmin, but as I was looking for an equivalent for PostgreSQL I stumbled upon Adminer.

It is basically a single file PHP script allowing to connect to and manage different DBMSs (namely MySQL, PostgreSQL, SQLite, MS SQL, Oracle, Firebird, SimpleDB, Elasticsearch and MongoDB) super easily.

Here are a few simple steps to use it on Homestead, but the process wouldn't differ much whatever your development environment is.

First, download adminer.php, rename it index.php and move it to an adminer folder under your usual Homestead projects directory.

Add a new site to your Homestead.yaml file (adapt the path to your own config if necessary):

sites:
    - map: adminer.local
    to: /home/vagrant/projects/adminer

Re-provision your box:

$ cd ~/Homestead
$ vagrant provision

Edit your local hosts file to match the Homestead box IP address to the domain (on a Mac that's /etc/hosts):

192.168.10.10   adminer.local

You should now be able to access http://adminer.local:

Adminer

To access the MySQL databases, simply select "MySQL" in the "System" dropdown, type "localhost" in "Server" (there is a placeholder that looks like the value is entered by default but you actually need to type it in), and the default "homestead" and "secret" as "Username" and "Password" respectively (you can also tick the "Permanent login" box so the details are added as a link on the left column for quick access).

The default PostgreSQL user doesn't have a password so you need to set one first.

ssh your Homestead box and run:

$ sudo -u postgres psql

You should be connected to PostgreSQL (notice postgres=# at the beginning of the prompt). Now type:

$ postgres=# alter user postgres password 'secret';

You've just set up a password for the default user ("secret", just like for MySQL). Quit this interface typing \q and try to access the PostgreSQL databases from Adminer (select "PostgreSQL" in the "System" dropdown, type "localhost" in "Server", and "postgres" and "secret" as "Username" and "Password" respectively).

I personnally don't like the default theme, and there are a few other designs available from the website. Download whichever you fancy (I went for "pappu687") and place the adminer.css file at the same level as the index.php file you moved earlier.

Refresh http://adminer.local. You're done!

Enjoying the content?

You can also subscribe to the RSS or Atom feed, or follow me on Twitter.

Last updated by osteel on :: [ adminer phpmyadmin database homestead laravel ]

Comments