Search code examples
mysqlubuntupercona

How to allow percona connection with root as non-sudo user on localhost?


I have default root user in my percona mysql8 installation.

Problem: when I first sudo -s and then mysql -u root -prootpw, then I can connect to the mysql. But I also want to allow nonroot users (eg a java application running under a nonroot account) to use the default user.

But I'm just getting:

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

So how can I force percona to allow root connections from localhost in non-root terminal users context?


Solution

  • mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'rootpw';
    mysql > FLUSH PRIVILEGES;
    $ systemctl restart mysql