1

I've just installed a copy of MySQL 5.7 for testing, and I love the fact that it now only creates a single root account, and puts the password into a file called .mysql_secret.

There's just one problem. Where can I find the above mentioned file. On Linux it is apparently found in $HOME, but my test DB is on Windows.

I tried various places including %USERPROFILE% but I just can't find it anywhere!!

Can anyone please tell me where to find this file? As otherwise my testing will be over before it has begun.

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
asked Jan 27, 2015 at 10:48

3 Answers 3

2

My blind guess would be to look in %APPDATA%\MySQL on your system as follows:

cd %APPDATA%
cd MySQL
dir .my_secret

For those who use the MySQL no-install Zip File (such as myself), you will not see one.

If .my_secret is not on your Windows servers, I have an alternative. You could start up mysqld manually with skip-grant-tables, set the password

net stop mysql
cd "C:\Program Files (x86)\MySQL\MySQL 5.7\bin"
start mysqld --skip-grant-tables
mysql -ANe"update mysql.user set authentication_string=PASSWORD('mynewpassword') where user='root'"
mysqladmin shutdown
net start mysql
mysql -uroot -p
Enter password: (enter the password 'mynewpassword' and hit <Enter>)

Give it a Try !!!

answered Jan 27, 2015 at 17:11
1
  • Cheers, that worked exactly as required. It turns out though, (after spending all last night reading the MySQL documents in detail) that, as far as I can tell, the .mysql_secret only applies to Linux. On Windows, it is still insecure and creates a root user with no password. I was inadvertently seeing a MySQL Bug (#75656) which is why I couldn't connect. Commented Jan 28, 2015 at 10:35
1

The .mysql_secret file is only used by mysql_install_db (which is deprecated).

The new way to bootstrap a server (mysqld --initialize) writes the randomly generated password to the error log.

answered Dec 15, 2015 at 21:11
0

Can you check your my.ini file? (inside MySQL folder)

There you should find something like:

[mysqladmin]
user=root
password=pwpwpw
port=3306
answered Jan 27, 2015 at 12:17
1
  • Cheers. I always take the username / passwords out of the ini file for security reasons. I put them back in under [mysqladmin] but it made no difference. Commented Jan 27, 2015 at 13:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.