Error
Error Code:
1698
MariaDB Error 1698: Access Denied No Password
Description
MariaDB Error 1698 indicates that a connection attempt was denied because the server expected a password for the specified user but none was provided. This typically happens when a user account is configured to require a password, but the connecting client or application attempts to authenticate without one, or with an empty password.
Error Message
Access denied for user '%s'@'%s'
Known Causes
3 known causesMissing Password in Connection
The client attempted to connect to MariaDB without providing any password for a user account that is configured to require one.
Empty Password Supplied
The connection attempt provided an empty string as a password, but the MariaDB user account requires a non-empty password for authentication.
Server Policy Disallows Empty Passwords
The MariaDB server or a specific security plugin is configured to reject connections from user accounts that do not have a password set.
Solutions
3 solutions available1. Set a Password for the User easy
Assign a password to the user account that is attempting to connect.
1
Connect to MariaDB as a user with sufficient privileges (e.g., root).
mysql -u root -p
2
Identify the exact user and host causing the error. The error message '%s'@'%s' will usually have placeholders that are filled in with the actual username and hostname.
SELECT user, host FROM mysql.user WHERE user = 'your_username' AND host = 'your_host';
3
Set a password for the identified user. Replace 'your_username', 'your_host', and 'your_new_password' with the actual values.
ALTER USER 'your_username'@'your_host' IDENTIFIED BY 'your_new_password';
4
Flush privileges to ensure the changes take effect immediately.
FLUSH PRIVILEGES;
5
Attempt to connect again with the new password.
mysql -u your_username -h your_host -p
2. Allow Passwordless Connection (with caution) medium
Configure MariaDB to allow connections from a specific user and host without a password.
1
Connect to MariaDB as a user with sufficient privileges (e.g., root).
mysql -u root -p
2
Identify the user and host from the error message.
SELECT user, host FROM mysql.user WHERE user = 'your_username' AND host = 'your_host';
3
Modify the authentication plugin for the user to 'unix_socket' if connecting from the same host as the MariaDB server and the user has a corresponding OS user. If not, you might need to consider other plugins or a more secure approach.
ALTER USER 'your_username'@'your_host' IDENTIFIED WITH unix_socket;
4
Alternatively, if you want to allow passwordless connections for certain hosts (e.g., localhost), you can grant privileges without requiring a password. **This is generally NOT recommended for production environments due to security risks.**
GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'your_host' IDENTIFIED BY '';
5
Flush privileges to apply the changes.
FLUSH PRIVILEGES;
6
Attempt to connect without a password. If using `unix_socket`, you might connect directly from the OS user.
mysql -u your_username -h your_host
3. Grant Privileges to an Existing User with No Password easy
If the user already exists but lacks necessary privileges or has an empty password, re-granting can resolve the issue.
1
Connect to MariaDB as a user with sufficient privileges (e.g., root).
mysql -u root -p
2
Identify the user and host causing the error.
SELECT user, host FROM mysql.user WHERE user = 'your_username' AND host = 'your_host';
3
Grant the desired privileges to the user. Replace 'your_username', 'your_host', 'database_name', and 'table_name' as needed. Using '*' for database and table names grants all privileges.
GRANT ALL PRIVILEGES ON database_name.table_name TO 'your_username'@'your_host' IDENTIFIED BY '';
4
Flush privileges to make the changes effective.
FLUSH PRIVILEGES;
5
Try connecting again.
mysql -u your_username -h your_host