ERROR 1045 - A big problem with the access to my mysql db - mysql

I was trying to execute "python manage.py migrate" in my project directory made in django.
The output was:
django.db.utils.OperationalError: (1045, "Access denied for user 'root'#'localhost' (using password: YES)")
So, I thought that I was having a problem with the db password of root user, I saw toturials to change the password, then, I try to enter with "mysql -u root -p" and it tried to enter but it did not accept, it said it was invalid. I tried "sudo" and if it worked, I changed the password and everything was fine. but when I try to migrate data I still have same dilemma.
django.db.utils.OperationalError: (1045, "Access denied for user 'root'#'localhost' (using password: YES)")
I assumed that I had to see that I could only do it with "sudo", the question is that I needed to use the data for my project to make use of them
auth': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'api_db_project',
'USER': 'root',
'PASSWORD': 'PASSWORDRANDOM',
'HOST': 'localhost',
'PORT': 3306
},
I thought that I had not solved the problem so I look for more guides and I find:https: //stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost
$ sudo mysql -u root # I had to use "sudo" since is new installation
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
$ service mysql restart
So when I try to test it still doesn't work, I see more guides and when I try to enter mysql to test more things, I can't even enter with "sudo", no password works and I don't know what to do at this point. This prints:
mysql: [ERROR] Found option without preceding group in config file /etc/mysql/mysql.conf.d/mysql.cnf at line 6.
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Does anyone know what happened? I am new in this :(
Here I leave some info
cat /etc/mysql/mysql.conf.d/mysql.cnf
#
# The MySQL database client configuration file
#
# Ref to https://dev.mysql.com/doc/refman/en/mysql-command-options.html
blind-address = 127.0.0.1
blind-address = *
blind-address = *
blind-address = 0.0.0.0
[mysql]
Ubuntu 20.04
mysql Ver 8.0.21-0ubuntu0.20.04.4
Django 2.2.2

I am not sure why you can't login. On a ubuntu 20.04 with MariaDB I just do
sudo mariadb
GRANT ALL ON *.* TO 'admin'#'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Maybe you can try this on yours. By default the root account is for login without password I think.

Related

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

I am trying to start mysql-client in Docker but i get access denied for user error

I am trying to connect MySQL Client to docker. I can connect just fine on the MySQL 8.0 Command Line Client, but when I try to connect to it from docker I get this error:
C:\Users\Bolin>docker exec -it mysql mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I am on a window machine and I am trying to follow this tutorial
https://phoenixnap.com/kb/mysql-docker-container
hmm, looks like the issue is with privilege user for the database table,
Try to create a privileged user in your database named root. After that please check again
==========================================================================================
try these queries in your databse:
INSERT INTO mysql.user (Host, User, Password) VALUES ('%', 'root', password('YOURPASSWORD'));
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
if the above code doesn't work try with the second
$mysql -u root mysql
$mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root';
$mysql> FLUSH PRIVILEGES;

Access denied for user 'root'#'localhost' (using password: NO) - what's wrong?

(Sorry for my English)
This is a log of my console:
anton#anton-X451CA:~$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
anton#anton-X451CA:~$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
What should I do? I understand that it appears when I try entering without a password, but I am dont confirmed password, and 'root'/empty string doesn't help.
I solved the problem, when:
Change the file my.cnf (in my Ubuntu-system he is placed at /etc/mysql/my.cnf). In the end i added that code:
[mysqld]
skip-grant-tables
That's helps enter in condole as anyone user without pass. Restart the server:
sudo service mysql restart
Enter in the mysql-console:
mysql -u root
Change the password for user root:
UPDATE mysql.user SET authentication_string=PASSWORD('root'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';FLUSH PRIVILEGES;
exit the console:
\q
Remove (or use commentary) for that in my.cnf (we dont need that settings now):
#[mysqld]
#skip-grant-tables
restart mysql-server:
sudo service mysql restart
That's all. :)
When you installed this fresh, you usually execute
mysql_secure_installation
afterwards. There you also set the initial password for your root account (note, that this is not the root account you have in Linux).
When you installed version 5.7. or higher the initial password is not blank anymore. You can find it in the error log. Find this log by looking in your my.cnf file. Default directory is /var/log/mysql, I think.

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

I can't access mysql ERROR: 1045(28000)

I had installed lamp server in my Ubuntu 12.04 box when I tried to access MySQL I got this bug
ERROR 1045(28000) I tried many solution available in the internet nothing works.
These are all my bash scripts I had tried to access it :
root#sampath-codyowl:~# mysql -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
root#sampath-codyowl:~# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
First try this
mysql -h 127.0.0.1 -u root -p
If that worked then add root#localhost
GRANT ALL PRIVILEGES ON *.* TO root#localhost IDENTIFIED BY 'root-password' WITH GRANT OPTION;
Other reasons:
Check if there is a firewall blocking your mysql port(mysql default is 3306)
Make sure that the server has not been configured to ignore network connections. look for --skip-networking, or --bind-address flags.
Check this article : http://dev.mysql.com/doc/refman/5.0/en/access-denied.html