mysql> ERROR 1044 (42000): Access denied for user 'root'#'localhost' - mysql

Initially I tried to setup a connection between MySQL and Node.JS and got error ER_NOT_SUPPORTED_AUTH_MODE, which I tried to fix by issuing ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password' and flushing privileges as described here. But after that I got another error ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'localhost', which I tried to solve by dropping and creating new user, among other steps as suggested on this page.
However, now I am unable to create any database at all, getting ERROR 1044 (42000): Access denied for user 'root'#'localhost' to database 'test'. I login successfully to MySQL command line client with the password that I setup during the installation but it seems I am not allowed to perform any operation there. How could I restore my privileges to create databases on MySQL v 8.0 on Windows 10?
Here is some other output which I get after issuing certain commands:
mysql> select user(), current_user;
+----------------+----------------+
| user() | current_user |
+----------------+----------------+
| root#localhost | root#localhost |
+----------------+----------------+
1 row in set (0.00 sec)
mysql> CREATE DATABASE test;
ERROR 1044 (42000): Access denied for user 'root'#'localhost' to database 'test'
mysql> mysql -u root -p;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql -u root -p' at line 1
mysql>

Related

how to fix ERROR 1044, ERROR 1046 and being unable to change password to users?

I'm already too tired of trying so many different things and I can't even bypass an error which is running. I know some of you might think it's a duplicate question, but I've seen dozens of questions, so I don't think the answer is so simple, nor is duplicated.
This are some of the many solutions I unsuccessfully tried:
update command is denied for user
Can't change user password on MySQL using UPDATE
Error: select command denied to user '<userid>'#'<ip-address>' for table '<table-name>'
MySQL Error: #1142 - SELECT command denied to user
https://mariadb.com/kb/en/set-password/
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
https://forums.mysql.com/read.php?10,588296
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
# mysql -u root -p
when it asks for password, no matter what I type it shows
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 430
Server version: 10.3.23-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
show databases; only shows
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.002 sec)
when I type
MariaDB [(none)]> use mysql;
ERROR 1044 (42000): Access denied for user 'root'#'%' to database 'mysql'
Notice it says % instead of localhost, is that a hint of something going on? have you encountered the same problem and were able to solve that?
even if I type the right password. I have another user but I can't change its password.
MariaDB [(none)]> select user, plugin from user;
shows
ERROR 1046 (3D000): No database selected
I feel like I really tried everything, I mean I've been like this for so many hours now, and I've changed mysql passwords many times in the past, using console in windows and linux, I have no idea what's going on!
EIDT: as suggested in comments here is the output for SELECT user, host, plugin from mysql.user;
MariaDB [(none)]> SELECT user, host, plugin from mysql.user;
ERROR 1142 (42000): SELECT command denied to user 'root'#'localhost' for table 'user'
here's the output to > SHOW GRANTS;
MariaDB [(none)]> SHOW GRANTS;
+---------------------------------------------------------------------------------------------------------------+
| Grants for root#% |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `root`#`%` IDENTIFIED VIA unix_socket USING '*227A46552108541F24FF4915F91' |
+---------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

(2003, "Can't connect to MySQL server on 'mysql.server' (111)") error in pythonanywhere

I am trying to deploy a django project on pythonanywhere but it is giving error-
(2003, "Can't connect to MySQL server on 'mysql.server' (111)")
I have seen many questions already asked for this problem but no answer solves my problem. May be there is a previlleges problem with accessing the database .
Database settings are-
DATABASES = { 'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mutechrobotics$mutech_db',
'USER': 'mutechrobotics',
'PASSWORD':'root',
'HOST': 'mysql.server',
} }
On running show grants command following databases are displaying(Actually i only need one database out of them but i am unable to drop the extra ones)
mysql> show grants ;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for mutechrobotics#% |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mutechrobotics'#'%' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH MAX_USER_CONNECTIONS 3 |
| GRANT ALL PRIVILEGES ON `mutechrobotics$default`.* TO 'mutechrobotics'#'%' |
| GRANT ALL PRIVILEGES ON `mutechrobotics$mutechnew_db`.* TO 'mutechrobotics'#'%' |
| GRANT ALL PRIVILEGES ON `mutechrobotics$mutech_db`.* TO 'mutechrobotics'#'%' |
| GRANT ALL PRIVILEGES ON `mutechrobotics$mu_db`.* TO 'mutechrobotics'#'%' |
+-------------------------------------------------------------------------------------------------------------------------------------------+
5 rows in set (0.00 sec)
my.cnf file is-
[client]
password = "root"
When i try to give all previleges to user- "mutechrobotics" then i am getting the following error-
mysql> GRANT ALL PRIVILEGES ON *.* TO 'mutechrobotics'#'%'
IDENTIFIED BY PASSWORD 'root';
ERROR 1045 (28000): Access denied for
user 'mutechrobotics'#'%' (using password: YES)
While trying to login as a root i am getting the error as-
mysql> mysql -u root -p ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql
-u root -p' at line 1
Somebody please help me sort out this problem.
Using mysql.server as the hostname is deprecated. According to the official PythonAnywhere Django tutorial, you should now use:
'HOST': 'username.mysql.pythonanywhere-services.com',

the mysql root account becomes ''#'localhost'

I think the root account has lost all privileges,or this root account has been replaced by ''#'localhost'
I use windows 7.
I login in the mysql with root account
C:\Users\Administrator>mysql -u root -p
Enter password: ******
when type use mysql,i got this
mysql> use mysql
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
then i type show databases;,there are only two
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.04 sec)
This is the net user
C:\Users\Administrator>net user
\\my-201501121940 的用户帐户
---------------------------------------------------------------------
Administrator Guest
命令成功完成。
C:\Users\Administrator>mysql -u root -p admin
Enter password: ******
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'admin'
I can't use root account to do anything, so I want to restore root privileges, can someone help me?

MySQL uses empty username in the connection error message

I found a strange mysql behaviour I am struggling to explain
[vagrant#Subs ~]$ mysql -u root12 subdb
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'subdb'
It uses empty string '' as the user name in the error message even though I explicitly supplied root12. If I provide the right username it connects with no problems so I suspect it is just the way mysql reports the error.
Is this a bug or undocumented feature?
[vagrant#Subs ~]$ mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
EDIT
People seem to be confused by the wording of this question. I am using root12 as the username, not the password. I am also saying mysql there is no password for root12. Furthermore, root12 user does not even exist. So it is a clear authentication failure. My question is why instad of saying
ERROR 1044 (42000): Access denied for user 'root12'#'localhost' to database 'subdb'
it says
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'subdb'
EDIT
Running CentOS6.5, mysql 5.1.73 here. testuser user does not originally exist
[vagrant#Subs ~]$ mysql -u testuser subdb
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'subdb'
[vagrant#Subs ~]$ mysql -u root
...
mysql> CREATE USER 'testuser'#'localhost' IDENTIFIED BY 'testpassword';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[vagrant#Subs ~]$ mysql -u testuser subdb
ERROR 1045 (28000): Access denied for user 'testuser'#'localhost' (using password: NO)
It's clear from this output that MySQL (seems like only this version) is leaking info whether the username exists or not. If it does not exist the error message resets the username to empty string. If it does, mysql keeps the username intact
try as per below-
mysql -u root12 -p
It will ask you password and you need to supply root12 password.
but if root12 is password of root user then use below command-
mysql -u root -proot12

mySQL Permission Errors

When I attempt to create a database this happens:
mysql> CREATE DATABASE testing;
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'testing'
When I run select user(); this happens:
mysql> select user();
+-------------+
| user() |
+-------------+
| X#localhost |
+-------------+
1 row in set (0.00 sec)
When I attempt to login as root this happens:
> mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I have tried over 15 different GRANT and FLUSH PRIVILEGES methods. Including putting the commands in a text file and doing it that way. I am on Mountain Lion using mySQL Server and Sequal Pro for managing the database.
Sequal Pro tells me that I cannot add a database as well. I have attempted to completely reinstall mySQL and that didn't seem to work either. I am new to mySQL and just need to start creating a database, I am going through the Django Book tutorials before I start on a project.
The only way I am able to access mysql is if i use
mysql -u X -p
However, that leads back to my permission errors up top.