Ubuntu 18.04 install latest official PHP with tasksel (install lamp Stack)

Install LAMP Stack using tasksel

a. Install Tasksel:

apt install tasksel

b. Installl LAMP Stack

sudo tasksel install lamp-server

c. Install phpmyadmin

$ apt install phpmyadmin

After this instalation mysql root user haven’t any password and can login to mysql server only from SSH because in table mysql.user have authentification mode set to “auth_socket”( value of column plugin).

There is two options:

  1. change user root and set password for allowing to connect from phpmyadmin or other application
  2. leave user root available only for ssh ( column plugin with value “auth_socket”) and create a new user with admin privileges. With this settings you can login from ssh without password.
$ mysql -u root

1 Set Password for mysql root user

a)First, connect in sudo mysql

$ sudo mysql -u root

b)Check your accounts present in your db

mysql> SELECT User,Host,plugin  FROM mysql.user;
| User             | Host      | plugin                |
| root             | localhost | auth_socket           |
| mysql.session    | localhost | mysql_native_password |
| mysql.sys        | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
| phpmyadmin       | localhost | mysql_native_password |
5 rows in set (0.00 sec)

c)Change the plugin and set a password with a single command:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';

c.1) On MariaDB (<10.2) which is on the Ubuntu version 16 as of 2017 , to change plugin along with the password, here’s the query: 

UPDATE mysql.user SET plugin = 'mysql_native_password', Password = PASSWORD('secret') WHERE User = 'root';

d)Flush privileges:


2 Create a new user with root privileges and root root user unchanged

a)First, connect in sudo mysql

$ sudo mysql -u root

b)Create a new user. I named it “sql”:

CREATE USER 'sql'@'%' IDENTIFIED WITH mysql_native_password BY 'your_password';

c)Grant plivileges to new user “sql”:


Similar Posts