I am new to MySQL. I installed MySQL (version 8) in RHEL 7.7 using yum . Now , I am trying to configure MySQL.

[root@devdbvm278 ~]# cat /etc/my.cnf
# commented lines removed for readability


Once the installation was done, I started the mysqld using

# systemctl start mysqld

Now, when I try to log in as root user, I get the following error. I tried to fix it using some stuff I found from googling. But, no luck. Any idea what is wrong ?

[root@devdbvm278 ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@devdbvm278 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@devdbvm278 ~]# 

[root@devdbvm278 ~]# mysqld_safe --skip-grant-tables
-bash: mysqld_safe: command not found

[root@devdbvm278 ~]# mysqld --skip-grant-tables
2019-08-13T15:53:33.812294Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 19578
2019-08-13T15:53:33.815432Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2019-08-13T15:53:33.815507Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-08-13T15:53:33.815777Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17)  MySQL Community Server - GPL.
[root@devdbvm278 ~]# 

# mysqld --version
/usr/sbin/mysqld  Ver 8.0.17 for Linux on x86_64 (MySQL Community Server - GPL)

1 Answer 1


In the security section of the documentation it states:

If you do not know the initial random password, look in the server error log.

Try running the following command. It works for me on my 5.7 installation (which has the same instructions as the 8.0 version of the documentation):

sudo grep 'temporary password' /var/log/mysqld.log

It should tell you the initial password to use for root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.