1

I have just installed mysql-server on ubuntu system using the following command

sudo apt-get update
sudo apt-get install mysql-server

I have not set any password for root user.

And then according to the https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04

I need to run

mysql_secure_installation

to secure the installation

But running the above command, shows the following error.

sugushiva@instance-1:~$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none): 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none): 

It says if it is a fresh installation I can just press enter, but if I press enter it throws the error

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

Searched online and found the following

https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost#=

According to the above url

I need to change plugin for root user or create a new user, creating a new user is recommended

I am afraid that there might be some security issues changing the default root user plugin.

But my, mysql_secure_installation requires root password.

etra info:

sugushiva@instance-1:~$ sudo mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> select user, plugin from user
    -> ;
+------+-------------+
| user | plugin      |
+------+-------------+
| root | unix_socket |
+------+-------------+

and it is a google cloud compute engine's virtual machine instance

Sugumar Venkatesan
  • 4,019
  • 8
  • 46
  • 77

2 Answers2

1

Method: Change root Authentication Method

****strong textOpen up the MySQL prompt from your terminal:

1)sudo mysql

2)SELECT user,plugin,host FROM mysql.user WHERE user = 'root';

3)ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'enter_password_here';

4)FLUSH PRIVILEGES;

You should now be able to log in to phpMyAdmin using your root account.

0

You just need to use: sudo

i.e. sudo mysql_secure_installation

fvlasie
  • 73
  • 10