Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

mysql root login password

avatar
Explorer

I am using sandbox image HDF_3.0.2.0_virtualbox_28_11_2017.ova. I am trying to enable hive and start hive metadata database using mysql. I can't create database/user because I can't login in as root. I have tried empty password, hadoop, admin, hive, root, etc. Keep getting the same ERROR 1045 ( 28000): Access denied for user 'root'@'localhost'. Please let me know how I should proceed. Thanks

8 REPLIES 8

avatar
Master Mentor

@Long M

After you run the "mysql -u root -p" command when it asks for password please enter "hadoop" as password.

Example:

# mysql -u root -p
Enter password: hadoop

- Operating System password and MySQL passwords can be different.

But if you have changed mysql root password then you might want to look at the following link which talks about If you assigned arootpassword previously but have forgotten it, you can assign a new password.

https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

avatar
Master Mentor

@Long M

Please check your MySQL version. If it is 5.7 or above then A temporary password is generated. Which can be found inside it's log:

# sudo grep "temporary password" /var/log/mysqld.log

.

Please see: https://www.percona.com/blog/2016/05/18/where-is-the-mysql-5-7-root-password/

avatar
Master Mentor

@Long M

For more detailed answer on "skip-grant-tables" and resetting root password for mysql please refer to:

https://community.hortonworks.com/questions/141454/what-is-the-mysql-root-password-from-hive-install...

avatar
New Contributor

I tried 'hadoop' password -> not working

I tried sudo grep "temporary password" /var/log/mysqld.log -> not working

I tried https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html and I ended up with https://stackoverflow.com/questions/25700971/fatal-error-please-read-security-section-of-the-manual-... -> not working

Why on a sandbox I need a CIA/FBI hidden password for mysql ?! is it so important ?

ANY OTHER IDEAS ?

avatar
New Contributor

Ok after spending 1/2 day here what I did :

1- Find Ambaris password location :

	shell> grep "password" /etc/ambari-server/conf/ambari.properties

2- The output from previous command:

server.jdbc.user.passwd=/etc/ambari-server/conf/password.dat

3- Cat password.dat

[root@sandbox-hdp conf]# cat /etc/ambari-server/conf/password.dat //output is 'bigdata' from this command

4- Enter Ambaris postgreSQL db

bigdata[root@sandbox-hdp psql -U ambari
Password for user ambari:
psql (9.2.23)
Type "help" for help.
ambari=>

5- Execute the select:

Expanded display is on.
ambari=> select config_id,type_name,config_data from clusterconfig where type_name='hive-site' ORDER BY config_id DESC LIMIT 1;

6- From the output search for:

"javax.jdo.option.ConnectionPassword":"hortonworks1"

avatar
Rising Star

hortonworks1 --> This is the pwd

avatar

Thank you. It works

avatar
New Contributor

@adelin ghanayem

here you can find all the steps to change the root password:

1. Stop mysql:
systemctl stop mysqld

2.Set the mySQL environment option 
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"3.Start mysql usig the options you just set
systemctl start mysqld

4. Login as root
mysql -u root

5.Update the root user password with these mysql commands
mysql>UPDATE mysql.userSET authentication_string = PASSWORD('MyNewPassword')->WHEREUser='root'AND Host ='localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

*** Edit ***As mentioned my shokulei in the comments,for5.7.6and later, you should use 
   mysql>ALTERUSER'root'@'localhost' IDENTIFIED BY'MyNewPass';Or you'll get a warning

6. Stop mysql
systemctl stop mysqld

7. Unset the mySQL envitroment 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:7. mysql -u root -p

see more info at https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7