It seems that windows is not reading the HOSTS file properly, as a result only 127.0.0.1 is accepted NOT localhost.
To work around this:
Go to your wamp\apps\phpmyadmin.versionnumber\
Open config.inc.php
Change the localhost to 127.0.0.1
Save and restart all services
I have found a solution that is as strange as the problem itself.
Reboot MySQL/MariaDB using --skip-grant-tables
(search for tutorials on the web). (not necessary at all, read my edits at the end of the post)
Look at the plugin
field into the mysql.user
table:
MariaDB [mysql]> SELECT user, plugin FROM user;
+------+-------------+
| user | plugin |
+------+-------------+
| root | unix_socket |
| root | unix_socket |
| root | unix_socket |
| root | unix_socket |
+------+-------------+
I had to reset the plugin field of each entry to a blank string.
UPDATE user SET plugin=""; // without WHERE clause
Also, make sure that a password is defined, because sometimes it seems to be erased (select on user, password
fields). If not, update it with:
UPDATE user SET password=PASSWORD("my_password") WHERE user="root";
Privileges parameters need to be saved explicitly:
FLUSH PRIVILEGES;
Then, restart MySQL in normal mode and you should be able to connect to the root account.
This will not necessarily disable the connection via Unix socket. After my MySQL va repaired, in PMA, I can see that the connection is established through an Unix socket.
EDIT, some months later: I'm now used to have this problem come back frequently, I think at each update of MariaDB (or something like that). So I've got a better comprehension of the probem ; there's an UNIX_SOCKET plugin that can let you log in a MariaDB account without having to create a password, because it uses the shell's credentials to trust you, without having to enter any password. In fact, this plugin is an authentication plugin and not a method of communication with the SQL server. So you can safely disable it if you don't use unix socket as a logging-in method.
The only thing I can't explain is why the UNIX_SOCKET plugin is regularly set on each account of the database, without any action on my side.
This has the nice side effect that, when it happens, you can login to the SQL server without having to restart MariaDB with --skip-grant-tables
: just log-in to the system's root account, then just connect with mysql -u root
without password, then reset the plugin field in the way it is explained above.
EDIT 2: Confirmed, it happens on each MariaDB upgrade on Ubuntu.
Best Answer
There are definitely a lot of answers on the Internet pertaining to how to change the MySQL
root
user password. And the main takeaway I got from them in 2024 is this:The
mysqld_safe
(binary/shell script) is definitley no longer a part of the MySQL 8 package (8.0.36) in Red Hat 8 and possible other Linux distros.It might be gone (as a binary/shell script) from the MySQL install on
systemd
managed systems since at least MySQL 5.7.6 according to this other answer on Stack Overflow:Regardless of the reason, if you get this message when attempting to run
mysqld_safe
:And your system runs
systemd
(aka:systemctl
) then this is definitely the modern answer that will solve your problems in 4 easy steps! Here we go!mysqld
and restart it with the properMYSQLD_OPTS
:root
with no password:[password]
should be changed to whatever MySQL password you want it yo be set to: Note, I believe the firstFLUSH PRIVILEGES;
is connected starting up MySQL with theMYSQLD_OPTS
set to--skip-grant-tables
. Regardless, runningFLUSH PRIVILEGES;
doesn’t pose any risk/danger.MYSQLD_OPTS
and restart MySQL as follows:Now with all that done, try to login to MySQL as root with a password like this:
Hit Enter/Return, then enter your newly set
root
password and… et voilà! You should be logged into MySQL asroot
!Note: I chose to set the password with
caching_sha2_password
authentication plugin, but if you want to be more modern, you can usemysql_native_password
as follows: