just installed a fresh Ubuntu 16.04, I put MySQL on it, but when trying to go to it
$ mysql -uroot
Error
is issued
Error 1698 (28000): Access Denied for User ‘root’ @ ‘Localhost’
Although, I still can go there via
$ sudo mysql -uroot
Tell me how to make from under the usual user to go there?
Added from Comment:
put through
$ sudo apt-get install mysql-server
$ sudo apt-get install mysql-client
It was proposed to set the password for the user MySQL root, I left empty, and if I try to go with the -p flag, the system requests a password, I press ENTER, and the same error is given.
Answer 1, Authority 100%
How to debian – a mining distribution to reinstall the password for the Root MySQL user, described, for example, in this answer: How to find out a user’s root password for MySQL database in Ubuntu?
In order not to enter the password every time you call the MySQL client, you can use a custom configuration file: How to specify default values when you start the client MySQL?
Answer 2, Authority 75%
You can create a new user with full rights.
$ sudo mysql -uroot
Create User 'newuser' @ 'Localhost' identified by 'password';
GRANT ALL Privileges ON *. * To 'newuser' @ 'LocalHost';
Flush Privileges;
Exit;
$ mysql -unewuser -ppassword
To work with the base, use the new user NEWUSER instead of root.
Answer 3
I use such a request from root in Bash scripts:
mysql --user = root & lt; & lt; _eof_
Update MySQL.user Set Password = Password ('$ {mysql_pass}') where user = 'root';
Delete from mysql.user where user = '';
Delete from mysql.user where user = 'root' and host not in ('localhost', '127.0.0.1', ':: 1');
DROP DATABASE IF EXISTS TEST;
Delete from mysql.db where db = 'test' or db = 'test \\ _%';
Update mysql.user set plugin = 'mysql_native_password' where user = 'root';
Flush Privileges;
_EOF_
And then I do:
service mysql restart
Answer 4
in MariaDB Debian 9.5:
sudo mysql -u root
Use MySQL;
Update User Set Plugin = '' Where User = 'root'; - Want Be The Empty String !!!
Flush Privileges;
exit;