# MySQL ERROR 1698 (28000): Access denied for user 'root'@'localhost'

**Code:** `1698` · **Category:** MySQL · **Seen on:** MySQL

root uses the auth_socket/unix_socket plugin (Ubuntu/Debian default), so password logins as root fail.

## 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.

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mysql/1698-access-denied-for-root-auth-socket)
