MySQL ERROR 1698 (28000): Access denied for user 'root'@'localhost'
root uses the auth_socket/unix_socket plugin (Ubuntu/Debian default), so password logins as root fail.
Seen on:
MySQL
Meaning
On Ubuntu, root authenticates via the OS user: sudo mysql works, mysql -u root -p doesn’t. Apps should use their own user.
Common causes
- Ubuntu/Debian default auth_socket for root
- phpMyAdmin/app trying to log in as root with a password
⚡ Quick fix
- Use sudo mysql for admin tasks
- Create a dedicated app user with a password
- Or switch root to caching_sha2_password (not recommended for apps)
Detailed fix by platform
MySQL
sudo mysql -e "CREATE USER 'admin'@'localhost' IDENTIFIED BY 'StrongPass!'; GRANT ALL ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;"
How to diagnose
- Plugin — SELECT user, plugin FROM mysql.user WHERE user='root'
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026