ERROR 1698 (28000): Access denied for user 'superuser1'#'localhost' - mysql

I followed the instructions for Option 2 in the question ERROR 1698 (28000): Access denied for user 'root'#'localhost' and used superuser1 as my 'YOUR_SYSTEM_USER' (see code below).
$ sudo mysql -u root
mysql> USE mysql;
mysql> CREATE USER 'superuser1'#'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'superuser1'#'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='superuser1';
mysql> FLUSH PRIVILEGES;
mysql> exit;
$ service mysql restart
Now I get ERROR 1698 (28000): Access denied for user 'superuser1'#'localhost' when trying to log in to mysql as suggested in that answer, this error occurs even if I prepend sudo to the mysql command as shown below
hms011#hms011-OptiPlex-9010-AIO:~$ sudo mysql -u superuser1
[sudo] password for hms011:
ERROR 1698 (28000): Access denied for user 'superuser1'#'localhost'
hms011#hms011-OptiPlex-9010-AIO:~$
I'm using Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu) on Linux Mint 19
on a new desktop installation.
As a new mysql user I am being somewhat tentative when creating users until I become more familiar.
Should I perhaps change the plugin for my superuser1 to mysql_native_password?
The solution I followed suggested using no password (i.e. '') for the new user - will this affect any change of plugin?
I did look at the question MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES) and most other similar questions but could not see how any of the suggestions there would solve my issue - the suggested solution to my original issue did include using FLUSH PRIVILEGES which I followed (as I stated at the outset). My original issue (which remains) was ERROR 1698 (28000): Access denied for user 'root'#'localhost' Unlike some other users, it was not solved by using the recommended Option 2 in that thread. Hence I have raised my own issue, perhaps I was too succinct in my original description so have now included the code for option 2 solution mentioned above together with the resulting error when logging in.
In the absence of any assistance I have tried:
hms011#hms011-OptiPlex-9010-AIO:~$ sudo mysql -u root
[sudo] password for hms011:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant all privileges on *.* to 'superuser1'#'localhost' identified by 'toFFee8_&cHeese' with grant option;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
hms011#hms011-OptiPlex-9010-AIO:~$ mysql -u superuser -p
Enter password: {password was entered}
ERROR 1045 (28000): Access denied for user 'superuser'#'localhost' (using password: YES)
hms011#hms011-OptiPlex-9010-AIO:~$ sudo mysql -u superuser -p
Enter password: {password was entered}
ERROR 1045 (28000): Access denied for user 'superuser'#'localhost' (using password: YES)
So now I do get the ERROR 1045 (28000) but am none the wiser about why it (or the other errors) occurred.
Finally I went back to 'root' and re-granted all privileges to superuser1 I can now log in but without the password that was set up.
While this seems to be satisfactory I would prefer to know why it is so, in order to have confidence in what I have done
Solved
Eventually the whole problem seems to be solved after
Altering the plugin for both users to 'mysql_native_password'
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'auth_socket'
'auth_socket' was the existing plugin for root but for other Linux users it might be 'unix_socket'; and
- Setting a password for 'root' that does NOT include '&'

Related

How do I grant permissions to users in mysql?

How do I grant permissions to users in MySQL?
This is the order in which I tried:
First, connect from EC2 SERVER to MYSQL CLIENT RDS.
After connecting, MYSQL created a user to give you permission.
An error occurs when giving the user permission.
My attempt:
mysql> CREATE USER 'injekim'#'125.128.63.112' IDENTIFIED BY 'k12345678!!';
Query OK, 0 rows affected (0.02 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'injekim'#'125.128.63.112' WITH GRANT OPTION;
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
Also, I found similar error information in stackoverflow, but I couldn't solve it.
MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES)
How can I authorize the user who created it?
It looks like you are not logged into the host machine. To use the root user, you should actually be logged into the machine (ssh or rdp) that is hosting the MySQL server.
Example, let's say I am setting at my Mac but need to give a new user access to a MySQL database that is running on a server with an IP address of 192.168.1.10. Assuming it's a Linux server I would ssh to the server from my Mac's terminal by running:
ssh myuser#192.168.1.10
You can now either:
Log into MySQL as root by running: mysql -u root -p (you will be prompted for the password)
Or,
You could become the root user. In my case, I would run the following:
sudo su. Now that you are the root user, you can log into MySQL by running:
mysql -p
If you need an example in a Windows environment, let me know. It will be the same basic idea, but using RDP instead of ssh. From your local machine, get a session on the actual server running MySQL and then log into MySQL as root from the server.

Cannot log into any account on mysql from terminal

Ever since running as suggested: https://stackoverflow.com/a/50131831/3310334
alter user 'root'#'localhost' identified with mysql_native_password by 'Gzbz1H!fZ##LyF33IqP$rAS8H#0iNc4lK8l2Md#EHxJyFK2YgfQwiKxz*0#lykWvKdWzhxh6EYKu&6ZPp1#9$%YMPb6EfDPYf2h';
I can't access mysql anymore:
% mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
% sudo mysql
Password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
% mysql
ERROR 1045 (28000): Access denied for user 'theonlygusti'#'localhost' (using password: NO)
% sudo mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I copy/paste my password exactly as I used to (and the password used to be the same).
In fact, I have noticed that any account that I "altered" as above I cannot log into through the terminal anymore, but they work from within Node.js using require('mysql') package.
How can I regain access to the root account without losing all my databases?
I just made the problem probably-worse by running
ALTER USER 'root'#'localhost' IDENTIFIED WITH caching_sha2_password BY 'Gzbz1H!fZ##LyF33IqP$rAS8H#0iNc4lK8l2Md#EHxJyFK2YgfQwiKxz*0#lykWvKdWzhxh6EYKu&6ZPp1#9$%YMPb6EfDPYf2h';
from inside javascript (after connecting as root).
It was successful.
Now I can't connect to root using JavaScript or the terminal.
I just tried following advice: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
% cat init.sql
ALTER USER 'root'#'localhost' IDENTIFIED BY 'Gzbz1H!fZ##LyF33IqP$rAS8H#0iNc4lK8l2Md#EHxJyFK2YgfQwiKxz*0#lykWvKdWzhxh6EYKu&6ZPp1#9$%YMPb6EfDPYf2h';
% brew services stop mysql
% mysqld --init-file="$PWD/init.sql"
But I still can't connect by literally copy/pasting exactly the same password as above into the password prompt.
I have also tried the other reset method detailed in that link, using --skip-grant-tables:
% kill `cat /usr/local/var/mysql/theonlygustis-MacBook-Pro.pid`
% mysqld --skip-grant-tables
% mysql
> flush privileges;
> ALTER USER 'root'#'localhost' IDENTIFIED BY 'alter user 'root'#'localhost' identified with mysql_native_password by 'Gzbz1H!fZ##LyF33IqP$rAS8H#0iNc4lK8l2Md#EHxJyFK2YgfQwiKxz*0#lykWvKdWzhxh6EYKu&6ZPp1#9$%YMPb6EfDPYf2h';
> flush privileges;
> exit
% kill `cat /usr/local/var/mysql/theonlygustis-MacBook-Pro.pid`
% mysqld
% mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
It also doesn't work.
The preceding sections provide password-resetting instructions specifically for Windows and Unix and Unix-like systems. Alternatively, on any platform, you can reset the password using the mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management statements such as ALTER USER and SET PASSWORD. Because this is insecure, if the server is started with the --skip-grant-tables option, it also disables remote connections by enabling skip_networking.
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:
shell> mysql //or sudo mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'#'localhost' account password. Replace the password with the password that you want to use. To change the password for a root account with a different host name part, modify the instructions to use that host name.
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
You should now be able to connect to the MySQL server as root using the new password. Stop the server and restart it normally (without the --skip-grant-tables option and without enabling the skip_networking system variable).
If does not help. Can see official page
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html

ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES) after set plugin = ''

I have MySQL 5.7 installed and wanted to enable passwordless login for root.
So I executed
mysql> update mysql.user set plugin='' where User='root';
mysql> flush privileges;
Now I am not able to login anymore as root. Neither with the password nor without the password. I receive the following errors respectively:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
I read about solutions using mysqld_safe but I cannot use that since we are using systemd.
Any suggestions? Ideally without restarting mysqld but well ...
Also I tried
mysqladmin flush-privileges
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
"Suggestions?"
Accckkk! I can't fathom what would compel someone to think that root user login with no authentication is a good idea.
I suggest we reconsider the security implications of a "passwordless" login for a privileged user. (That would be red flag on a security audit.) If I absolutely had to implement a passwordless login (because every other possible alternative solution has been ruled out), I would ONLY do that for a user that had very strictly limited privileges.
To implement a "no password" login in MySQL, we can use 'native_mysql_password' for plugin, and use an empty string '' for password.
(I'm not aware of any reason we would want to set plugin to be empty string.)
Ok so I ended up stopping mysqld and did the following
systemctl stop mysqld
/usr/sbin/mysqld --skip-grant-tables &
mysql -u root
mysql> update mysql.user set plugin = 'mysql_native_password' where user = 'root';
mysql>flush privileges;
systemctl stop mysqld
systemctl start mysqld
And it's working again

Reset mysql root pass

I've been trying to reset the password for MySQL but all of the solutions I've found, nothing seems to work. I'm using OSX Yosemite with MAMP and MySQL 5.6.20
I attempted to reset the password via MAMP to pass but it does not work
$mysql -u root -p
Enter password: pass
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
$
and none of this works
$mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
$mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
$mysql -u root#localhost
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 62
Server version: 5.6.20 Homebrew
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use magento
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'magento'
mysql> SET PASSWORD FOR 'root' = PASSWORD('pass');
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
mysql> SET PASSWORD FOR 'root'#'localhost' = PASSWORD('pass');
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
mysql> SET PASSWORD FOR 'root'#'::1' = PASSWORD('pass');
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
You can stop mysql server and restart it with --skip-grant-tables option. That way it doesn't look at credentials when opening up a mysql shell
After that,
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;
Stop mysql server, and start it again
Just adding some details to Justin’s Kiang answer (which help me, thanks!).
On my OS X Machine:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server start --skip-grant-tables
mysql -u root
and then the SQL code as per Justin’s answer:
UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
FLUSH PRIVILEGES;
bye
And restarting the MySQL server again:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server start
Adjust your path to mysql folder if needed.

MySQL error :ERROR 1045 (28000): Access denied for user 'guest'#'localhost' (using password: YES)

I have a Linux EC2 instance which has MySQL server installed on it.
I can login with MySQL root with this command:
mysql -u root -p
For some reasons I created a user guest using following commands:
CREATE USER 'guest'#'%' IDENTIFIED BY 'passpass';
GRANT ALL PRIVILEGES ON * . * TO 'guest'#'%';
FLUSH PRIVILEGES;
Then I exit from root user and try to login with guest user:
mysql -u guest -p
entered the correct password and got this error:
ERROR 1045 (28000): Access denied for user 'guest'#'localhost' (using password: YES)
I even checked out for the anonymous user .
mysql> SELECT User, Host, Password FROM mysql.user WHERE User='';
Empty set (0.00 sec)
Kindly help. I am not able to connect to MySQL using guest user credentials
MYSQL AWS LINUX EC2 INSTANCE
I was trying to access mysql in AWS linux EC2 instance, but was getting the error:- Error: Access denied for user 'root'#'localhost'. After lot of searching I got the solution which worked for me.
So for mysql community server, the default password is randomly generated whenn you install.
Check /var/log/mysqld.log file, write vim /var/log/mysqld.log in terminal and search for the keyword "temporary password"- you will get the password.
Few configurations are required for mysql- sudo /usr/bin/mysql_secure_installation
it will ask for password then enter the "temporary password" collected earlier. and in the proceding steps question will be asked over there new password could be easily set. then can proceed with
mysql -u root -p.
try by Run the command
grant all on . to 'guest'#'%' identified by 'passpass';
flush privileges;
Thanks