Recently I was testing the MySQL database server on Ubuntu 17.10 / 18.04 and discovered that the MySQL database server now installs on Ubuntu without prompting the root user for a password to access the server. Is this new? It’s always been the case where MySQL prompts for passwords every time before access is granted to the server. Apparently, not anymore. Now simply installing the database gives the root access without passwords. and this may not be something everyone wants. Even after running the command sudo mysql_secure_installation. The root account password is never required. However, other applications and services that depend on MySQL will fail if the root password is needed for authentication. phpMyAdmin and MySQL Workbench database may fail if MySQL is set up this way. So, if you want to run phpMyAdmin and other MySQL tools that require root authentication, you may want to enable the mysql_native_password plugin. This brief tutorial is going to show students and new users how to set a root password for MySQL and allow password authentication. After digging a bit, I discovered that MySQL uses the unix_socket plugin to authenticate, and not passwords. Even if you set a password, it is ignored. To re-enable password authentication, follow the steps below: Login to the MySQL server by running the commands below Notice no password? That should get you into the database server. After that, run the commands below to disable plugin authentication for the root user Restart and run the commands below to set a new password. After that, run the commands below to secure the MySQL server and create a new root password. When prompted, answer the questions below by following the guide.

Enter current password for root (enter for none): Just press Enter Set root password? [Y/n]: Y New password: Enter password Re-enter new password: Repeat password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]:  Y Reload privilege tables now? [Y/n]:  Y

You should now be able to log on with password authentication. and other applications should now work with the root password authentication. The next time type the commands below to logon Then type the password to sign on Enjoy!