The way I use the mysql server on my local computers is by mysql_native_password authentification method.
0. Preparation. If you have any errors and no databases to keep I recommend starting clean. For this reason lets fisrt remove all packages and databases with:
sudo apt purge mysql*
if you do not have the purge command, you can install it by
sudo apt install purge
1. Install mysql server
sudo apt install mysql-server
2. Remove dangerous defaults and lock-downs of the database
2.1 VALIDATE PASSWORD PLUGIN. There are two options here, to make my life easier I use the No option and always chose a strong password. There is an option to use it with Yes, and configuration instructions if you follow the link I will provide later, but I never succeed to have phpMyAdmin running if I use Yes.
2.2 Remove anonymous users: In most cases you do not need them so I recommend Yes
2.3 Disallow login remotely: I use Yes, because I do not want remote logins to my local database, but if you plan to do this via SSH for example, you better choose No. Otherwise, Yes is more safe and it always can be changed using the same secure instalation wizard
2.4 Remove test database and access to it: Yes. Unless you need it for some reason you better remove it.
2.5 Reload privilage tables now: Yes, because you want the changes made already to be active.
3. Switch authentification method of root user from auth_socket to mysql_native_password. This is necessary if you wish to not using the sudo command every time you login into mysql database, also to use native phpAdminLogin with the same root password. First you need to login into mysql using the auth_socket:
Because you will login into mysql command line interface, the shell prompt will be
mysql>. Make sure to replace the string your_root_password below with the password you want to use for the mysql root account, but put it in inside the ' '.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_root_password';
Use the next command to flush the privileges:
In order to leave the mysql command interface and go back to bash console execute:
From now on you will be able to login using
mysql -u root -p but if you try
sudo mysql -u root -p you will have an error because the authentification method is changed from auth_socket to mysql_native_password.
On the next link you can see a complete guide how to install LAMP on ubuntu 18.04, with more detailed explanation of the mysql part, including options if you choose VALIDATE PASSWORD PLUGIN to be Yes. I do not say it is wrong to be done this way, but I never succeeded to make it work using the password validation.
This complete guide above I use every time when I face any problems during installing LAMP on Ubuntu 16.04 and 18.04 based operation systems. The version on the link is for ubuntu 18.04, but it actually is an updated version for the ubuntu 16.04 from the same website I have used with Loki and Ubuntu 16.04. Good luck!