Do you want to use your Mysql server without root password (as a non-root user) in Ubuntu 16.04 and newer? Still struggling getting it work?
After installing Mysql in non-interactive mode, the service starts with socket authentication. It means that only the root user can log in and no other user. To install a Mysql server in a completely automatic way without a root password you may use the following commands (as root):
apt-get install -y apache2 php mysql-server
echo "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';" | mysql -u root
echo "FLUSH PRIVILEGES;" | mysql -u root
This few lines will install your Mysql server in a non-interactive way and root access will be enabled without a password. Have fun!