I have installed MySQL community edition in the Centos machine, I want to access the MySQL service by just typing mysql instead of mysql -uroot -p<password>, I have done so sort configuration adding the username and password in the my.cnf that is not gone work anymore it throwing
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: YES)
As error is defined ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES), you are using the wrong password for accessing mysql.
You can also update username & password using cli
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; & restart mysql using sudo service mysql restart
Thanks
Related
When I try to enter the root user from MySQL Workbench and manually enter it, I get the following error:
your connection attempt failed for user root to the mysql server
Access denied for user 'root'#'localhost' (using password: YES)
I am using mysql -u root code when I want to connect to MySQL via cmd and I get an error in it:
mysql: Unknown operating system character set 'cp857'.
mysql: switch to the default character set of 'utf8mb4'.
ERROR 1045 (28000): Access was denied for the user 'root'#'localhost' (using password: No)
I get a similar error when I try to log in using a password, the only thing that changes is (using password: YES).
What had I better do?
Issue with your password so simply change mysql root password.
here command
mysql -u root
then
mysqladmin -u root password [newpassword]
may help you this.
thanks
I just installed MySQL Version 8.0.27 on my windows machine, whenever i try to run MySQL command i get this error
ERROR 1045 (28000): Access denied for user 'ODBC'#'localhost' (using password: NO)
and when i try to run MySQL -u root -p i get this error after specifying password
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Also i can't locate my.ini file. i was thinking if i should add my.ini file manually or download another version of mysql
I fixed my issue by installing mysql version 5.6.11
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 try to access MySQL but I can't. I wrote skip-grant-tables in the mysql configuration and restart it but it still doesn't work.
$ mysql -u root -p
ENTER PASSWORD: *****
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I also try to connect phpmyadmin but I can't
Cannot log in to the MySQL server
and
mysqli_real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES)
Error meaning:
SQLSTATE[28000] [1045] Access denied for user 'user'#'localhost'
(using password: YES)
Possibilities:
Typo in password
Accessing from the wrong host
User doesn’t exist
But in your scenario, I don't see a chance for case 3. But cases 1 and 2 are possible.
Can you check if your password is correct, i,e. no typo in your password.
If you have a wrong password you can reset the admin/root password by starting the MySQL in safe mode.
UPDATE user SET password=PASSWORD("new_password") WHERE User='root';
In the second case, the reason is MySQL allows user access only from hosts defined in the MySQL user table.
it can be resolved by starting the MySQL in safe mode and
UPDATE user SET host='hostname' WHERE user='username';
I am on Ubuntu. I did not set any password to my root account during the MySQL installation process. I am trying to run MySQL with
mysql -u root
However, I can't, ending up with the following access denied error.
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Then, I thought it might be due to the password issue. I tried this and enter an empty password and hit the Enter key.
abc#ubuntu:~$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Then, I even tried entering a password (my user password on the computer). I ended up with this
abc#ubuntu:~$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I have seen some solutions, but most of them require to run MySQL first in order to resolve the issue. However, I find myself not able to do anything, stuck here.
You must login from root so for this you must write sudo like:
sudo mysql -p
First give your system password
then it asking for mysql server password, in my case '123'
Then you acces your database.
Your command looks ok. It looks like you need to reset the root password
Resetting MySQL root password