I recently encountered this error “ERROR 1524 (HY000): Plugin ‘unix_socket’ is not loaded” on my Debian 9 server while trying to authenticate to MariaDB database as a root user. After some googling, I found the workaround for this error is to start MySQL service with mysqld_safe
and reset the root password.
Step 1: Stop mysql service
Stop MySQL service.
$ sudo systemctl stop mysql
# OR
$ sudo /etc/init.d/mysql stop
Step 2: Start mysql with mysqld_safe
Then start mysql service with mysqld_safe
--skip-grant-tables
$ sudo mysqld_safe --skip-grant-tables &
[1] 8197
Step 3: Reset root user password
Open MySQL terminal console.
$ sudo mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.14-MariaDB-1:10.3.14+maria~stretch mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
You should get to MySQL terminal without password authentication. Now switch to mysql
database.
MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
Reset root user password.
MariaDB [mysql]> update user set password=PASSWORD("NewRootPassword") where User='root';
Query OK, 0 rows affected (0.002 sec)
Rows matched: 1 Changed: 0 Warnings: 0
Replace NewRootPassword
with your new password for root user.
Also set Authentication plugin to native.
MariaDB [mysql]> UPDATE USER SET plugin="mysql_native_password";
Query OK, 2 rows affected (0.001 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Close your Database session.
MariaDB [mysql]> quit;
Bye
Step 4: Start MySQL Service normally
Restart mysql service in a standard manner. But first stop the service.
$ sudo systemctl stop mysql
#OR
$ sudo /etc/init.d/mysql stop
Ensure no other process is running.
ps aux | grep mysql
Start mysql.
sudo systemctl start mysql
Test access as root user.
$ mysql -u root -p
Enter password: <Enter Password Set>
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.14-MariaDB-1:10.3.14+maria~stretch mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> QUIT
Bye
Video Courses to help you Learn MySQL:
- The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert
- SQL – MySQL for Data Analytics and Business Intelligence
- SQL for Beginners: Learn SQL using MySQL and Database Design
- Learn Database Design with MySQL
- The Complete MySQL Developer Course
- MySQL Database Administration: Beginner SQL Database Design
- MySQL, SQL and Stored Procedures from Beginner to Advanced
Similar articles.
How to reset MySQL root password
How to Reset RDS Master User Password on AWS
How to reset forgotten WordPress admin password
How to reset root password in RHEL / CentOS 8
How to Reset FreeIPA admin Password as root user