Log-in to mysql only with sudo

Asked

Viewed 260 times

-2

When I’m at the linux terminal, on my machine and give the command :

mysql -u root -p

The linux terminal presents :

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

With sudo before the command, I can log in, however, what appears on my screen are line-log-in mariaDB

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.1.37-MariaDB-0+deb9u1 Debian 9.6

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
  • 1

    Right, but what’s your question about that?

  • Only run sudo mysql that will directly log in and configure

2 answers

0

In the new versions Mysql and Mariadb it use the plugin unix_socket that uses the user credentials to make the connection to the bank. Do the following test, type the command $sudo mysql or #mysql and see that if it will connect to the bank and not need to inform user or password. To know which user has this configuration run the following SQL.

MariaDB [(none)]> SELECT User, Host, plugin FROM mysql.user where user = 'root';
+------+-----------+-------------+
| User | Host      | plugin      |
+------+-----------+-------------+
| root | localhost | unix_socket |
+------+-----------+-------------+
1 row in set (0.000 sec)

Take a look at this forum also

-1

Why did I see you try to use sudo at first? Do you use Ubuntu? Do you use Java? You also need to create a password for Mysql if you need to communicate with some applications, see some post on the internet has several, hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.