Mysql 8 access denied at the first time access

centos
mysql
Category Software and digital electronics / IT
2023-01-06 04:59

Background

I have installed CentOS 8 and a mysql 8.

When I try to have an access to it for the first time,

mysql -u root -p

I will be asked for the password and whatever I try, I face with an error

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Were to find my password for the first time?

Answered by robin
2023-01-06 05:17

For a fresh installation of mysql 8, you can find your temporary password by this command:

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

Now, that you have the temporary password,

mysql -u root -p

and then

mysql console
alter user root@localhost identified by 'your-new-password';
flush privileges;
×

Login

No account?
Terms of use
Forgot password?