Reputation: 11
MaraidaDB version: 10.3.38
Ubuntu(Azure): 20.4
when do 'sudo systemctl start mariadb', ubuntu don't notice error.
but when do 'sudo systemctl status mariadb', following eroor exist
Access denied for user 'root'@'localhost' (using password: NO)
I think that this error means when do 'sudo systemctl start mairadb', ubuntu require 'root' password of mariadb.
but when do 'sudo systemctl start mariadb', ubuntu don't require 'root' password.
help me please. ....................................................................
Upvotes: 0
Views: 301
Reputation: 53
Same problem with Debian 11.7 and MariaDB 10.6
oct. 19 15:52:17 bart1 mariadbd[886478]: 2023-10-19 15:52:17 9 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
oct. 19 15:52:17 bart1 debian-start[886699]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
→ Content of file : /etc/mysql/debian.cnf
# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE.
# This file exists only for backwards compatibility for
# tools that run '--defaults-file=/etc/mysql/debian.cnf'
# and have root level access to the local filesystem.
# With those permissions one can run 'mariadb' directly
# anyway thanks to unix socket authentication and hence
# this file is useless. See package README for more info.
[client]
host = localhost
user = root
[mysql_upgrade]
host = localhost
user = root
# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE.
Solution found:
By adding the following line at the end solve the problem.
It also resolve a problem about MariaDB log rotation (logrotate using mysqladmin --defaults-file=/etc/mysql/debian.cnf ...
)
!include /root/.my.cnf
Content of /root/.my.cnf
[client]
password=your_password
About the future, i think i will not change root password but i'll create new user with permissions.
Upvotes: 0
Reputation: 7516
Since Debian 9 and Ubuntu 15.04 the default authentication on the local machine is done via unix_socket authentication: The unix_socket authentication allows the user to use operating system credentials when connecting to MariaDB via the local Unix socket file.
If you changed the authentication method and/or password for the root user, the systemd status call will of course fail, since the root user cannot connect to the MariaDB server anymore.
Upvotes: 0