1

I have installed fresh MySQL server on CentOS, and started the MySQL server service with command.

 # /sbin/service mysqld start

I checked the service and it is running.

Currently I am logged in as root@localhost. I want to changed the password for root. For this I have issued the command:

/usr/bin/mysql_secure_installation

Once I issued this command, system is asked for password, I tried to just hit "enter". This does not work. Also, tried my Linux root password that also does not work.

When I tried to hit enter I am getting:

Error: Access denied for user 'root'@'localhost' (using password : NO)

When I tried with Linux box local root password I am getting:

Error: Access denied for user 'root'@'localhost' (using password : YES)

Other than local machine root password, it did not ask me for any password during installation time. What I am missing here? What should I do to login from the mysql-workbench? Thanks.

1
  • The password is probably the word root.
    – Will
    Feb 6, 2016 at 0:28

2 Answers 2

1

edit /etc/my.cnf and add:

skip-grant-tables

then restart MySQL service and try to login

mysql

also you can check [official manual]:

0

There is probably a root password stetup there normally you should run mysql_secure_installation as root that will prompt you for mysql root password and there just hit enter.

In your case it looks like there is a root password setup you can change it by using

sudo mysqld_safe --user=mysql --pid-file=/var/run/mysql/mysqld.pid --socket=/var/run/mysql/mysql.sock --datadir=/var/lib/mysql --skip-grant-tables

This will let you start mysql and you can mysql -u root into mysql after that is matter of updating root password.

mysql> use mysql; 
mysql> update user set password=PASSWORD("yournewrootpasshere") where User='root';
mysql> flush privileges;
mysql> quit

--skip-grant-tables option is the key using that it will not prompt for a password.

After this if you restart mysql normally it will come up and you can even run mysql_secure_installation again with you new root pass if you want.

Since this is a fresh install you can also remove mysql package and reinstall it as well. Remember to remove database as well.

1
  • for this I tried to hit enter and that did not work
    – LilRazi
    Feb 5, 2016 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .