I’ve recently done this. I just used php7.1 instead of 7.0


So for mysql, I type root for the password as I cannot leave root password blank. Then I go to localhost/phpmyadmin, but I can’t login via username: root and password: root.

I’ve been looking at some guides here and there, but no cigar.

Though one thing I noticed is there currently is non for 5.0 Juno.

Can somebody help me out?

  • 1
    Did you tried $ mysql -u root -p as your guide says? If it worked then is only a phpmyadmin configuration problem
    – Sebastian
    Commented Jan 1, 2019 at 22:07
  • The guide you listed here is incomplete - some important keypoints are missing. For anyone in a similar position I can recommend a better guide to instal LAMP stack on ubuntu 18.04 based OS - digitalocean.com/community/tutorials/…
    – Bo rislav
    Commented Dec 13, 2019 at 15:02

5 Answers 5


Since you have not deployed a site and their are easier options out there. I recommend removing everything you have done thus far and selecting one of the two options below.

Remove previous LAMP installs

sudo apt-get purge mysql* apache* php*
sudo apt autoremove && sudo apt autoclean

Use tasksel to install LAMP

sudo apt install tasksel
sudo tasksel install lamp-server

Firstly grab and install EE:

sudo wget -qO ee rt.cx/ee4 && sudo bash ee

Now for a LEMP stack run:

sudo ee site create example.com

For a Wordpress LEMP install:

sudo ee site create example.com --type=wp
  • using tasksel for installing LAMP is the best option
    – Alexandr
    Commented Oct 2, 2019 at 16:23

When you first install mysql server and the installation does not ask for root password, it takes auth_socket as default plugin for mysql root user, which does not allow root connections without sudo. You can test this if you run mysql -u root(ERROR 1698: Access denied for user 'root'@'localhost') and sudo mysql -u root.

There are two solutions:

Change default plugin for root user

It is already explained here. The mentioned error will appear in other programs that can use mysql root user too, therefore this is a all-in-one way to solve it

Create a new user with root privileges (It is not recommended that you use mysql root user for common usage, so i recommend this option)

Enter into mysql with sudo (no password needed)

sudo mysql -u root

Create a new user (replace phpmyadmin_user and password with yours)

mysql> CREATE USER 'phpmyadmin_user'@'localhost' IDENTIFIED BY 'password';

Grant root privileges to the new user (You can also specify what databases and tables you're granting privileges to with databases.tables, * is a comodin)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin_user'@'localhost';

Now you should be able to login into phpmyadmin with the new user/password.

  • The linux root user is different than the phpmyadmin user, and creating a different phpmyadmin user is useless because the phpmyadmin uses the mysql root user password to manipulate the myslq databases.
    – Bo rislav
    Commented Dec 13, 2019 at 0:10
  • Mysql does not allow you to login as root(mysql user) without using sudo (as you can see in linux terminal running "mysql -u root -p" no matter if the password is correct), for that reason you can't login as (mysql) root in phpmyadmin
    – HYAR7E
    Commented Dec 13, 2019 at 0:37
  • It looks like mysql allows me to login without sudo: mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.28-0ubuntu0.18.04.4 (Ubuntu) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    – Bo rislav
    Commented Dec 13, 2019 at 0:42
  • Here it says: mysql -u root -p Enter password: ERROR 1698 (28000): Access denied for user 'root'@'localhost' And using sudo mysql -u root -p it goes on normally. I had this error when i was first using mysql in linux just after installing it, it's cuz default plugin was auth_socket wich does not allow root connections withou sudo permissions, you can see more about here link
    – HYAR7E
    Commented Dec 13, 2019 at 1:19
  • It is really strange.. I have more than 7 years experience of installing mysql into OSX and Linux computers and even now I have 2 LAMP stacks into elementary Loki and Hera and I was never using sudo with mySQL unless to install mysql server. As long as all these 100+ has the answer helpful, probably there is something like this, or all of you are doing some great mistake. Later today will try to install it into ubuntu 18.04 to see what is going on.
    – Bo rislav
    Commented Dec 13, 2019 at 5:24

As Juno has an Ubuntu 18.04 base, the following might work. (Mariadb)

sudo apt install mariadb-server mariadb-client
sudo mysql_secure_install

This will set a root password. You may have to use

sudo mysql -u root -p

there onwards.

  • Okay so this installs mysql 5.7. Which also gave me more problems because it wouldn't allow me to login as root via phpmyadmin. I've looked at solutions here and there, but I'll try it once again later. Commented Oct 23, 2018 at 4:17

For some reason, in Ubuntu 18.04, the MySQL workbench will also have the same issue, try this and it works for me. Reference

  • Your participation is much appreciated👍 Let me inform you that we love informative answers with step by step guide. Please try to include the answer here and leave the source link. Don't forget to say 'no' to spam! Have a nice day!
    – Hasan
    Commented Dec 12, 2019 at 18:32

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

sudo mysql_secure_installation

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:

sudo mysql

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.