My php -v is

php -v
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies

i try to install php apache to my ubuntu and it asks me to enter root password. But i cant find the password. I follow this guide


Step 3 – Install MySQL i do those

sudo apt install mysql-server php-mysql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php-mysql is already the newest version (1:7.0+35ubuntu6).
mysql-server is already the newest version (5.7.13-0ubuntu0.16.04.2).
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-28 linux-headers-4.4.0-28-generic
  linux-image-4.4.0-28-generic linux-image-extra-4.4.0-28-generic
  linux-signed-image-4.4.0-28-generic linux-signed-image-4.4.0-31-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 54 not upgraded

and then this

sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)

Probably i had php or mysql before.

I cant reach that file. I used ubuntu root passsword root is not that root.

 gedit /etc/php/7.0/apache2/php.ini

also doesnot show password.



  1. Stop MySQL Service:

    sudo service mysql stop

  2. Kill all running mysqld:

    sudo killall -9 mysqld

  3. Starting mysqld in Safe mode:

    sudo mysqld_safe --skip-grant-tables --skip-networking &

  4. Start mysql client:

    mysql -u root

  5. After successful login, please execute this command to change any password:


  6. You can update mysql root password:

    UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

...this did not work for me so i did:

In MySQL 5.7, the password field in mysql.user table field was removed, now the field name is authentication_string.

First choose the database:
mysql> use mysql; And then show the tables:
mysql> show tables; You will find the user table, and see its fields:  
mysql> describe user; You will realize there is no field named password, the password field is named authentication_string. So, just do this:
update user set authentication_string=password('XXXX') where user='root'; As suggested by @Rui F Ribeiro, alternatively you can run:
mysql> SET PASSWORD FOR 'root' = PASSWORD('new_password');
  1. Please execute this command:


  2. Exit mysql console:


  3. Kill mysqld_safe and start mysql:

    sudo killall mysqld_safe && sudo service mysql start

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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