Skip to content

Instantly share code, notes, and snippets.

@sandipklevu
Created April 8, 2026 05:34
Show Gist options
  • Select an option

  • Save sandipklevu/a143abd3072c00f303d987141546eb3f to your computer and use it in GitHub Desktop.

Select an option

Save sandipklevu/a143abd3072c00f303d987141546eb3f to your computer and use it in GitHub Desktop.
Fix MySQL 8 Error ERROR 1524 (HY000): Plugin ‘auth_socket’ is not loaded in ubuntu 24
#!/bin/bash
sudo systemctl stop mysql
sudo killall -9 mysqld
sudo killall -9 mysqld_safe
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo mysqld_safe --skip-grant-tables --skip-networking &
sleep 5
# In MySQL 8.x, we use ALTER USER or a direct UPDATE to the authentication_string
mysql -u root <<EOF
FLUSH PRIVILEGES;
-- This sets the password to 'password' and fixes the plugin error
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
EOF
# Clean up: Kill the safe mode process and restart normally
sudo killall mysqld
sleep 2
sudo systemctl start mysql
echo "Process complete. Use password as password, Try logging in with: mysql -u root -p"
@sandipklevu

Copy link
Copy Markdown
Author
sh fix-mysql-8.sh 

2026-04-08T05:30:48.059893Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2026-04-08T05:30:48.083563Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2026-04-08T05:30:54.133435Z mysqld_safe mysqld from pid file /var/lib/mysql/user.pid ended
Process complete. Use password as password, Try logging in with: mysql -u root -p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment