Vagrant machine - how to find out mysql username/password

14,800

Solution 1

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)

Solution 2

Just tried all passwords mentioned above (root, empty string, 123, etc.), nothing helped. I am using this box https://app.vagrantup.com/brownell/boxes/xenial64lemp.

After half an hour of bruteforcing, found that the password for root user is secret

Solution 3

The answer for me to log in to MySQL on vagrant was with a username of root and when prompted for the pasword I just pressed enter. I.e...

Username : root

Password: (none, just press enter)

Solution 4

I believe the default is root:root for most of them.

$ mysql -u root -p Enter password: ...

Share:
14,800
MilanG
Author by

MilanG

I want to call my self game developer, but everybody else is calling me web developer. Check out my LibGDX apps: https://play.google.com/store/apps/details?id=com.mgsoft.arkanoid https://play.google.com/store/apps/details?id=com.mgsoft.reversi https://play.google.com/store/apps/details?id=com.mgsoft.oldcompass https://play.google.com/store/apps/details?id=com.mgsoft.soldiers

Updated on June 29, 2022

Comments

  • MilanG
    MilanG almost 2 years

    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.

  • MilanG
    MilanG over 7 years
    Not for this one. Frederic hacked it out.
  • Ramazan Zülkarneyn
    Ramazan Zülkarneyn over 4 years
    I enter this file /etc/mysql/debian.cnf get username password and use PHPMyAdmin host = localhost user = debian-sys-maint password = 7WpHbEJmn1MxcfD9 and login phpmyadmin changed user password. thanks.