Dharmaraja.k
Dharmaraja.k

Reputation: 533

Access Denied fro user 'root@localhost' on centos 7

I am a newbie to CentOS .

I want to setup Mysqlfabric with multiple mysql servers in a single machine.

First i want to setup the Mysql instances. The following steps followed but i could not start the single mysql server instance.

step 1. Fresh installation of centos 7

setp 2. Added the required Yum repository for mysql-community-server.version.noarch.rpm.

setp 3. Installed yum mysql-community-server (The mysql version is 5.7.10 installed.)

step 4. Checked the mysqld status with systemctl status mysqld.

step 5. systemctl start mysqld.services

step 6. now i want to check mysql shell.

step 7. I had checked the mysql client also it is already installed while mysql commuinty server has installed.

step 8. For the mysql root user not prompted the password so i had tried with the default password . like mysql -u root -p mysql

It is asking Enter password .
tried with different password but i am getting the error like 
ERROR 1045 (28000) : Access denied for user 'root'@'localhost' (using password: YES).
Another way also tried with mysql_secure_installation but i am getting the same error. i dont know how to resolve this. 
Mysqladmin -u root password = 'newpassword' also tried. But i am getting the access denied error. 

The root password not yet set up but access denied. i dont know how to resolve this . Please help me to resolve. Thanks in advance.

After first instance successfully running only i can proceed with multiple instances and need to configure mysqlfabric. Please help me.

I had referred the mysql installation link http://sharadchhetri.com/2014/07/31/how-to-install-mysql-server-5-6-on-centos-7-rhel-7/

Upvotes: 4

Views: 41357

Answers (3)

ButcherFromHell
ButcherFromHell

Reputation: 165

Actually MySQL --skip-grant-tables option is used to start the MySQL server without loading the grant tables so it means statements related to accounts management are disabled

So you can't:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables 
option so it cannot execute this statement

you have to load grant tables to the MySQL server using the FLUSH PRIVILEGES:

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.01 sec)

and then step 5

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

Hope it helps someone

Upvotes: 2

Manikanta Vasupalli
Manikanta Vasupalli

Reputation: 29

  1. Stop MySQL:
    systemctl stop mysqld

  2. Set the mySQL environment option
    systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

  3. Start MySQL using the options you just set
    systemctl start mysqld

  4. Login as root without a password
    mysql -u root

  5. ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

  6. Stop MySQL
    systemctl stop mysqld

  7. Unset the MySQL environment option so it starts normally next time
    systemctl unset-environment MYSQLD_OPTS

  8. Start MySQL normally:
    systemctl start mysqld

Try to login using your new password:
mysql -u root -p

Upvotes: 2

Dharmaraja.k
Dharmaraja.k

Reputation: 533

Finally i resolved the problem on centos7 with mysqlserver 5.7.10.

The reason behind is mysql server 5.7.10 generating the random password for the mysql.

so the following commands will be resolved my problem.

step 1. login as root

step 2. grep 'temporary password' /var/log/mysqld.log

step 3. It will show the password.

step 4. Copy the password and do the following ,

4.1 mysql -u root -p

4.2 Enter the temporary password

4.3 The mysqlserver 5.7.10 has security so you need to update the password for further process in mysql shell.

so do the following

ALTER USER 'root'@'localhost' identified by 'your new password';
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

4.4 Now do all the process in mysql shell.

Thanks to all.

Upvotes: 14

Related Questions