1698 🐬 MySQL

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

  1. Use sudo mysql for admin tasks
  2. Create a dedicated app user with a password
  3. Or switch root to caching_sha2_password (not recommended for apps)

Detailed fix by platform

MySQL

  1. sudo mysql -e "CREATE USER 'admin'@'localhost' IDENTIFIED BY 'StrongPass!'; GRANT ALL ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;"

How to diagnose

  1. Plugin — SELECT user, plugin FROM mysql.user WHERE user='root'
  2. 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.