Animesh Pandey Animesh Pandey - 3 years ago 163
SQL Question

Access denied while running Mysql for the first time on Centos

I just installed Mysql for the first time on a CentOS machine using

yum
. The installation had no errors. Then I followed those steps:

$ sudo /sbin/service mysqld start --skip-grant-tables --skip-networking

$ sudo /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter current password for root (enter for none):


It can be seen that even after first installation there is issue in logging in to the DB. I have even tried all command in
sudo
, but the error is still there. I can't even figure out how to reconfigure MySQL. I halso have installed-removed mysql 3 times.

How can I solve this issue?

Answer Source

Maybe you already setted it at some point. You can try this:

yum remove mysql-server
rm -rf /var/lib/mysql
yum install mysql-server
systemctl start mysqld.service
/usr/bin/mysql_secure_installation

Anyway, I think this question should be in ServerFault.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download