MySQL Login Error: "Plugin 'auth_socket' is not loaded"
Problem: Attempts to connect to MySQL via CLI result in a series of errors, including "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded."
Solution:
This error occurs after resetting the root password and changing the authentication plugin to "mysql_native_password." To resolve it:
-
Run Bash Commands:
- Stop MySQL service: sudo /etc/init.d/mysql stop
- Start MySQL without password: sudo mysqld_safe --skip-grant-tables &
- Connect to MySQL as root: mysql -uroot
-
Run MySQL Commands:
- Use MySQL table: use mysql;
- Update root user's password to an empty string: update user set authentication_string=PASSWORD("") where User='root';
- Change root user's authentication plugin to "mysql_native_password": update user set plugin="mysql_native_password" where User='root';
- Flush privileges: flush privileges;
- Quit MySQL: quit;
-
More Bash Commands:
- Stop and restart MySQL: sudo /etc/init.d/mysql stop; sudo /etc/init.d/mysql start
- Login to MySQL without entering a password: mysql -u root -p
Additional Tips:
-
If a socket error occurs, try these commands:
- sudo mkdir -p /var/run/mysqld; sudo chown mysql /var/run/mysqld
- mkdir -p /var/run/mysqld && chown mysql:mysql /var/run/mysqld
-
Instead of "localhost," use "127.0.0.1" for hostname:
- Skipping the "my.cnf" file may also resolve the issue.
The above is the detailed content of Why am I getting a 'Plugin 'auth_socket' is not loaded' error when connecting to MySQL?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn