Fresh mysql-server installation does not ask for password

Try this:

After installation, run MySql Secure Installation:

[email protected]:~ $ sudo mysql_secure_installation

You'll be asked a series of security related configuration questions, including setting the root password.

Once the root password is set, you'll need to be logged in as root (or use sudo) to login. This is a consequence of how MySql uses credentials based on process uid

If someone facing this problem in installing MYSQL in Ubuntu 18.04.

Ubuntu 18.04 uses sockets for authorization and not passwords!!


For me logging in was as simple as:

sudo  mysql -u root      

Don't forget the sudo

I really hope there should have been a message stating that Ubuntu no longer used passwords when attempting to run mysql. this was a really drastic change in functionality.

Here you go:

In the new my-sql if the password is left empty while installing then it is based on the auth_socket plugin.

The correct way is to login to my-sql with sudo privilege.

$ sudo mysql -u root -p

And then updating the password using:

$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';

Once this is done stop and start the mysql server.

$  sudo service mysql stop
$  sudo service mysql start

For complete details you can refer to this link.

Do comment for any doubt.