I work for a web-hosting company. I'm rather green, and being new, I only have non-root access to our clients' servers. Often, I need to troubleshoot mysql. Since I don't have root, I must use the clients' mysql credentials. These can be found in
~/<domain>/html/app/etc/env.php
an example block:
'db' => [
'table_prefix' => '',
'connection' => [
'default' => [
'host' => 'localhost',
'dbname' => 'xxxxx',
'username' => 'xxxxx',
'password' => 'xxxxx',
'model' => 'mysql4',
'engine' => 'innodb',
'initStatements' => 'SET NAMES utf8;',
'active' => '1',
'driver_options' => [
1014 => false
I need to extract dbname, username, and password from this block of the file on each unique server. Until now, I've just been using cat, but since each server has its env.php in a unique path (based on domain name) I don't know how to do this in a one-shot. Using find to search ~/ for env.php doesn't work since clients will often copy their site for backup and dev purposes, creating multiple files with that name.
My bash is very basic. Any tips are appreciated and will make my work much more efficient.
Until now, I have been moving into the site directories manually and navigating to the file I need. This is time consuming.
Edit: using basic grep to find these fields in the file doesn't work since it returns credentials from all blocks (redis, etc), and not just the mysql username/password.