msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

30 May 16 Resetting MariaDB root password in Ubuntu 16.04 LTS

Introduction:
Becasue it’s such a good article and don’t want to lose it, this following article is a full copy (with maybe some minor changes) taken from this site:
http://tecadmin.net/steps-to-reset-mariadb-root-password-in-linux/#

Step 1: Stop MariaDB Service
First we need to stop MariaDB service using following command.
# /etc/init.d/mysql stop
Shutting down MySQL. [ OK ]

Step 2: Start MariaDB in Safe Mode
Now connect to MariaDB in safe more using skip grant and run this command in background.
# mysqld_safe --skip-grant-tables &
.
[1] 6218
140118 22:27:09 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
140118 22:27:09 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Step 3: Login to MariaDB and Change Password
After starting MariaDB in safe more connect to MariaDB and run following commands to change root password.
# mysql
.
MariaDB [(none)]> use mysql;
MariaDB [mysql]> UPDATE user SET password=PASSWORD("new_password") WHERE User='root';
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> quit;

Step 4: Stop and Start MariaDB
After changing password, stop the MariaDB service and start it again in normal mode using following commands.
# kill $(ps aux | grep -v 'grep' | grep /usr/bin/mysqld_safe | awk '{print $2}')
# service mysql start

Step 5: Login to MariaDB using New Password
At this stage you have successfully updated you root MariaDB password, Lets connect to MariaDB using new password.
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 1
Server version: 5.5.34-MariaDB MariaDB Server
.
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
.
MariaDB [(none)]>

RESULTS:
Well, after having done all of the above I could sign-up as root via the command line ‘mysql -u root -p’ but could not sign-up as root via PHPMyadmin.
So here is what I did:
Step 6: login as root using this command:
# mysql -u root -p
Step 7: Enter the following commands to create the new user ‘root2’ and set the same password as for ‘root’
MariaDB [(none)]> use mysql;
MariaDB [mysql]> CREATE USER 'root2'@'localhost' IDENTIFIED BY 'same_pass_as_root';
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root2'@'localhost' WITH GRANT OPTION;
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> quit;

I could then login as ‘root2’ in PHPMyadmin and have all privileges as for root.
That works and don’t ask me why đŸ˜‰

Reader's Comments

  1.    

    your tutorial is work thank you very much đŸ™‚

    Reply to this comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: