I installed MySQL (fresh) on my Ubuntu 18.04. And I'm having problems logging into the database. During installation there was no request for password and when I try
mysql -u root -p
the password was somehow set and I do not not how it is possible as it's a fresh installation.
Because I was confused, I tried removing MySQL packages as was somewhere suggested
sudo apt-get remove -y mysql-* sudo apt-get purge -y mysql-*
After this I made a new installation
sudo apt-get install mysql-server
but the result is the same. Not possible to login as root without password. I went through many discussions about root password reset and no success.
I tried to start mysql server with special init file via
mysqld --init-file=/home/me/mysql-init &
the file consisted of
UPDATE mysql.user SET Password=PASSWORD('pass') WHERE User='root'; FLUSH PRIVILEGES;
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I also tried
sudo dpkg-reconfigure mysql-server-5.7
5.7. is correct version of my mysql server, but no result - as I read in another discussion this is possibly obsolete solution but I tried it anyway.
I also tried
sudo mysqld_safe --skip-grant-tables --skip-networking & mysql -u root UPDATE user SET authentication_string=PASSWORD('newpass') WHERE user='root'; FLUSH PRIVILEGES;
but the new password does not work at all.
During installation there should be a request for root password, right? Or how can the password be set in the new installation? I'm quite new to Linux but I would expect that reinstall with purge should remove all settings and the new installation should be without root password?