Sometimes you want to show all users in Trellis. Just to be sure a certain database user is there. I for example keep on forgetting the database username generated based on the group_vars/group/vault.yml. And I need it to access the database properly with Sequel Pro . So how do we do this?
SSH into Box
To figure this out you first need to ssh into your Vagrant box or VPS. This you can do using
to access your Vagrant box or
to access your staging or production server. Next you can work on accessing the database.
Then you need to enter
mysql -u root -p
to access the MySQL database. Then you add the root password which IS easily found in that same file:
In our case the vault.yml for development. For production you will use something tougher of course. So in our case (local development on Vagrant) and most of your cases working locally with standard settings this will then be devpw.
Display all Database Users
Well you can now do this database query to get all users:
SELECT User FROM mysql.user;
You will then see a list similar to this one:
MariaDB [(none)]> SELECT User FROM mysql.user; +------------------+ | User | +------------------+ | root | | root | | root | | debian-sys-maint| | example_com | | root | +------------------+ 6 rows in set (0.00 sec)
Only in our case we have a slightly adjusted box. The main user we were looking for is example_com here. Trellis generates a username based on the domain or projectname. One with a underscore instead of the dot.
The password is shown in the same file:
No comment yet, add your voice below!