I am trying to install mysql after i replaced my disk with MySQL on it with a bigger and faster one. After installing mysql-server
on ubuntu, when running select user,host,authentication_string from user where user='root';
, authentication_string
is blank.
I set my password but the only way to login to root is to run the MySQL command with sudo and if I try to put the password in if I run mysql -u root -p
it doesn't work. I have also tried to just leave the password blank when logging in and it has had no effect. Any help is greatly appreciated.
System info: pop!_os amd64 20.04 (ubuntu like)
Some installations default to enabling the MySQL (and MariaDB) socket authentication plugin.
Rather than using password authentication it is sufficient to be logged in as
root
on the operating system (either by logging in directly asroot
or by usingsudo mysql
to elevate your privileges to root) to log in asroot
to the MySQL server. You can use the same mechanism for a regular users too, i.e. when I log in asbob
to the Linux server and abob@llocalhost
account exists in MySQL I can log on directly without additional authentication.To remove socket authentication log in as root
Set up a root with a password instead of the socket authentication
Activate these changes by flushing all cached credentials
Then you can log in with
mysql -u root -p
and the new password you assigned.