MilanG MilanG - 3 months ago 15
MySQL Question

Vagrant machine - how to find out mysql username/password

So, on atlas.hashicorp.com there are a lot of pre-installed machines, with PHP & MySql. But problem is, I can't find anywhere MySql credentials. I.e.:

https://atlas.hashicorp.com/webinfopro/boxes/ubuntu-xenial-lamp

I can access PhpMyAdmin, but I can't login. Tried all "usual" combination of username/password (root, vagrant, 12345678). But none of them works.
What's the point of installing MySql, when you don't give root user credentials?!?

I also followed some instructions to reset root user password:

https://help.ubuntu.com/community/MysqlPasswordReset

But I'm getting bunch of errors and process eventually fails. I'm not interested in debugging and solving numerous issues - just want to quickly have usable PHP 7 LAMP environment.

Answer

tldr;

Passwords are 123

how to get there :

After I spin a VM from this box, I logged in and check few files from the mysql conf, and specially the file /etc/mysql/debian.cnf

[12:41 ]-[vagrant@symfony]-[/etc/mysql]
$ sudo more debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = 7WpHbEJmn1MxcfD9
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = 7WpHbEJmn1MxcfD9
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

so I could connect using the user from this file

[12:41 ]-[vagrant@symfony]-[/etc/mysql]
$ mysql -u debian-sys-maint -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
....

I checked the user in table already created

mysql> SELECT User, Host, Password FROM mysql.user;
+------------------+-------------+-------------------------------------------+
| User             | Host        | Password                                  |
+------------------+-------------+-------------------------------------------+
| root             | localhost   | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| root             | symfony.dev | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| root             | 127.0.0.1   | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| root             | ::1         | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| debian-sys-maint | localhost   | *8275381EF253977AC1CD84B53CAFE742E4288272 |
| phpmyadmin       | localhost   | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+------------------+-------------+-------------------------------------------+
6 rows in set (0,00 sec)

so they all contained the same password .. ring the bell, checking

mysql> select password ('123');
+-------------------------------------------+
| password ('123')                          |
+-------------------------------------------+
| *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+-------------------------------------------+
1 row in set (0,00 sec)