Fun at work!

Posts tagged ‘root password’

How to add a user to sudoers file?

You need root access to add a user to the sudoers file. Enter as root user:

# su -

and put in the root password. Then use this command

# visudo

to make changes on the /etc/sudoers file. It is not recommended to edit the file using text editor.

To add a user, enter the line in appropriate location.

username    ALL=(ALL) ALL

or,

%groupname  ALL=(ALL) ALL

How to reset MySQL root password?

It is easy to forget the root password as it is advised to use the user account for security reason. Today, I needed to access my MySQL database as root, but I could not remember the password. After searching for a solution, I found this method to be awesome:

1. Run the server with –skip-grant-tables option so that you can log in without a password.

# /etc/init.d/mysqld stop
# mysqld_safe --skip-grant-tables &
$ mysql -u root

2. Reset the root password.

mysql> use mysql;
mysql> update user set password=PASSWORD("YOUR-NEW-ROOT-PASSWORD") where user='root';
mysql> flush privileges;
mysql> quit

3. Restart MySQL and log in using your new root password.

# /etc/init.d/mysqld stop
# /etc/init.d/mysqld start
# mysql -u root -p
 

Tag Cloud