I cannot figure out my MySQL root password; how can I find this out? Is there any file where this password is stored?
I am following this link but I do not have dir
In your "hostname".err file inside the data folder MySQL works on, try to look for a string that starts with:
"A temporary password is generated for roor@localhost "
you can use
less /mysql/data/dir/hostname.err
then slash command followed by the string you wish to look for
/"A temporary password"
Then press n, to go to the Next result.
You cannot find it. It is stored in a database, which you need the root password to access, and even if you did get access somehow, it is hashed with a one-way hash. You can reset it: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
Answers provided here did not seem to work for me, the trick turned out to be: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
(complete answer here: https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/)
you can view mysql root password , well i have tried it on mysql 5.5 so do not know about other new version well work or not
nano ~/.my.cnf
The procedure changes depending the version of MySql. Follow the procedure exactly as described for your version:
HINTS - Read before the instructions page for your version of MySql*
In step 5: Instead of run CMD, create a shortcut on your desktop calling CDM.exe. Then right-click on the shortcut and select "Execute as Administrator".
In step 6: Skip the first proposed version of the command and execute the second one, the one with the --defaults-file parameter
Once you execute the command, if everything is ok, the CMD window remains open and the command of step 6 continues executing. Simply close the window (click 'x'), and then force close MySQl from the Task Manager.
Delete the file with the SQL commands, and start again MySQL. The password must be changed now.
5.0 http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
5.1 http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html
... just change the version in the link (5.5, 5.6, 5.7)
You can't view the hashed password; the only thing you can do is reset it!
Stop MySQL:
sudo service mysql stop
or
$ sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
$ sudo mysqld_safe --skip-grant-tables
(above line is the whole command)
This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:
$ mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
MySQL 5.7 and over:
mysql> use mysql;
mysql> update user set authentication_string=password('password') where user='root';
Start MySQL:
sudo mysql start
or
sudo /usr/local/mysql/support-files/mysql.server start
Your new password is 'password'.