┌─────────────────────┐
│ │
│ MySQL/mariadb │
│ │
└─────────────────────┘
==> If you enter to MySQL as normal user with this command (by entering the root password), everything is fine:
$ mysql -u root -p
==> If no...
######################################################
########## CONFIG NEW versions of mariadb ##########
(debian 13)
# mariadb-secure-installation
Enter current password for root (enter for none): [ENTER]
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Thanks for using MariaDB!
Now, if you enter to MySQL as normal user with this command (by entering the root password), everything is fine:
$ mysql -u root -p
######################################################
####### CONFIG OLD versions of MySQL/mariadb #######
(debian 11, debian 12, ubuntu server 20 ...)
# mysql_secure_installation
Enter current password for root (enter for none): [ENTER]
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Thanks for using MariaDB!
Now, if you enter to MySQL as normal user with this command (by entering the root password), everything is fine:
$ mysql -u root -p
######################################################
######### CONFIG OLD OLD versions of MySQL #########
(debian 8, debian 9, debian 10 ...)
# mysql -u root
USE mysql;
UPDATE user SET plugin='mysql_native_password' WHERE user='root';
FLUSH PRIVILEGES;
exit;
# systemctl restart mysql.service
# mysql_secure_installation
Enter current password for root (enter for none): [ENTER]
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Thanks for using MariaDB!
Now, if you enter MySQL as normal user with this command (by entering the password), everything is fine:
$ mysql -u root -p
########################################################
### Change MySQL admin password NEW mariadb versions ###
# mysql -u root
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';
mysql> FLUSH PRIVILEGES;
mysql> exit;
##############################################################
### Change MySQL admin password OLD MySQL/mariadb versions ###
# mysql -u root
mysql> SET PASSWORD FOR 'user'@'localhost' = PASSWORD('your_new_password');
mysql> FLUSH PRIVILEGES;
mysql> exit;
Or you can also try...
# mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('your_new_password') WHERE User='root' AND Host='localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;