1

I have tried to follow all the suggestions here but none worked for me. I have installed mysql community server on Fedora mysql-community-server-5.7.9-1.fc21.x86_64

I have tried to access the temporary password using sudo grep 'temporary password' mysqld.log but it does not return any password.

I keep getting error Access denied for user 'root'@'localhost' (using password: NO)

I get this error when i execute mysqld_safe --skip-grant-tables

2016-06-14 10:46:00 3495 mysqld_safe: Logging to '/var/log/mysqld.log'. chown: invalid user: ‘@MYSQLD_USER@’ 2016-06-14 10:46:00 3495 mysqld_safe: The file @libexecdir@/mysqld does not exist or is not executable. Please cd to the mysql installation directory and restart this script from there as follows: ./bin/mysqld_safe& See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information

I am not able to reset the root user password. Please help.

Coder
  • 3,090
  • 8
  • 49
  • 85

2 Answers2

3

For mysql 5.7 on centos

systemctl stop mysqld
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
systemctl start mysqld
mysql -u root
mysql> use mysql; 
mysql> update user set authentication_string=password('you new pass') where 
user='root';
mysql> flush privileges; 
mysql> exit

systemctl restart mysqld
Aiden Wang
  • 141
  • 1
  • 4
0

RESET MYSQL ROOT PASSWORD( for linux users)

Login to root user and run

Step 1# /etc/init.d/mysql stop 
Step 2# mysqld_safe --skip-grant-tables & 
Output : Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started

Step 3 Login to new terminal (with root user)
    
   [#] mysql -u root

mysql> use mysql; 
mysql> update user set password=PASSWORD('NEW-ROOT-PASSWORD') where User='root';
mysql> flush privileges; 
mysql> quit

Step 4 # Stop MySQL Server:

/etc/init.d/mysql stop

Step 5 # /etc/init.d/mysql start

mysql -u root -pNEWPASSWORD

--------------------- completed----------

Community
  • 1
  • 1
Mohit M
  • 769
  • 7
  • 15
  • This isn't "recovering" the password; it's just setting one where one didn't exist. The step "Login to new terminal (with root user)" is not going to work if the root user has an unknown password. – underscore_d Jun 13 '16 at 13:48
  • You may need to login root user of your linux machine then you will able to get access of all mysql commands – Mohit M Jun 14 '16 at 08:10