This question already has answers here:
MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES)
(43 answers)
Closed 4 years ago.
I have MAMP installed and I've never had a problem with it. Today I tried logging in to PHPMyAdmin and I got the following error message:
1045 - Access denied for user 'root'#'localhost' (using password: YES)
In my config.inc.php file, the following options are set:
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'root';
I've never changed my password. This is a local install, so I've always used 'root' for username and password.
I've tried accessing MySQL through the terminal:
/Applications/MAMP/Library/bin/mysql
But I get this:
ERROR 1045 (28000): Access denied for user 'boneill'#'localhost' (using password: NO)
Not sure what could have happened. I haven't changed passwords or anything like that. It just stopped working all of a sudden. Any ideas?
Start MAMP
The MySQL server must be running to change the password, open and start MAMP now. keep it running until the end of this.
Mac Terminal
With the MySQL server running, open the terminal (located in '/Applications/Utilities') enter or copy/paste the following:
/Applications/MAMP/Library/bin/mysqladmin -u root -p password
You'll be prompted for a password. Enter the current password for the root user. If you changed it in phpMyAdmin, use that password.
Mosty password is blank so just press Enter and Enter Your New Password.
$ /Applications/MAMP/Library/bin/mysqladmin -u root -p password
Enter password:
$ /Applications/MAMP/Library/bin/mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
Now You Have to make changes in some file:
You need to replace all occurrences of the old root password with the new one you just created. To keep it easy here is a list of the files, you can open them in your favorite text editor and search for 'root', changing
'-proot' to '-p NewPassword', replacing 'NewPassword' with your own.
/Applications/MAMP/bin/phpMyAdmin/config.inc.php
/Applications/MAMP/bin/checkMysql.sh
/Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
/Applications/MAMP/bin/repairMysql.sh
/Applications/MAMP/bin/stopMysql.sh
/Applications/MAMP/bin/upgradeMysql.sh
Stop and restart MAMP
I hope that works/make sense because this works for me.
If I were you, I would just take your htdocs folder and just reinstall mamp. I've had this issue occur installing wordpress locally, setting the config file with a db user without a password, and then changing the password after the config was created in the installation process. I don't know why I did this but this installed wordpress with a user without a password, when the database required a password, so it then was giving me an authentication error.
Taking into consideration that you seem to have trouble debugging the issue, I think the most easiest way to rule out some of the probabilities is to install:
MySQL Workbench
It's free and you can use it as a GUI to try logging in to "localhost" or better "127.0.0.1" port 3306, user "root", password as you've chosen.
If you still notice an error connecting to the database, go to control panel -> services and check the status of the MySQL database. It might have crashed. Try to restart the service. If it shuts down again immediately, check your disk space. If you are running low on disk space, tables might have got corrupted. Also, check your firewall rules. If you are working in a corporate environment, somebody may have deployed new security polices - this might lead to port blocking, application networking issues etc. pp. -- even on your local host. Automatic windows updates might cause those changes too.
If it works using MySQL workbench, you can rule out any issue on database side. You can focus on PHP / MAMP then. Check the version and if any update has been installed (probably automatically). Is php mysql module installed and configured (php.ini, ensure php mysql dll is loaded).
Go to MAMP dashboard and Click on MySQL tab.
There button called "Change password for user "root":
Click on the button and change it.
Thats it.
I changed the password which is needed to login the mariaDB and in ssh I changed config.php file.
define('DB_PASSWORD', 'new password');
and when entering my page it said fail to connect to the database. I think mysql service needs to be restarted but it requires root authority and I don't know what root's password is. Is there other ways to connect to the database in ftp server or know the root's password?
use FLUSH PRIVILEGES; command in mariaDB.
https://mariadb.com/kb/en/mariadb/flush/
I just wiped my Mac and did a fresh install of El Capitan. I'm struggling to connect to Mysql now. Having gone through a web server setup process, I've created a simple PHP test file:
<?php
$conn = new mysqli("127.0.0.1", "root", "xxxxxxxx");
if ($conn->connect_error) echo "Connection failed: " . $conn->connect_error;
else echo "Connected successfully";
phpinfo();
?>
When I run it, I get this error:
Warning: mysqli::mysqli(): (HY000/1862): Your password has expired. To log in you must change it using a client that supports expired passwords. in /Users/rich/Documents/DESIGN/test/index.php on line 3
Connection failed: Your password has expired. To log in you must change it using a client that supports expired passwords.
I've never seen that response from a connection before. How do I fix it if I can't connect?
EDIT
In terminal I entered the command:
mysql -u root -p
This asked me for my password (current one) which I put in. I now have access to mysql commands but anything I try results in this error:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
How do I reset the password using ALTER USER?
So I finally found the solution myself.
Firstly I went into terminal and typed:
mysql -u root -p
This asked for my current password which I typed in and it gave me access to provide more mysql commands. Anything I tried from here gave this error:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
This is confusing because I couldn't actually see a way of resetting the password using ALTER USER statement, but I did find another simple solution:
SET PASSWORD = PASSWORD('xxxxxxxx');
First, I use:
mysql -u root -p
Giving my current password for the 'root'.
Next:
mysql> ALTER USER `root`#`localhost` IDENTIFIED BY 'new_password',
`root`#`localhost` PASSWORD EXPIRE NEVER;
Change 'new_password' to a new password for the user 'root'.
It solved my problem.
mysqladmin -u [username] -p password worked for me on OS X El Capitan and MySQL 5.7.12 Community Server. Example:
$ /usr/local/mysql/bin/mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
This is similar to pavan sachi's answer, but with password prompts.
My error was "#1862 - Your password has expired. To log in you must change it using a client that supports expired passwords." at phpMyAdmin login screen first time.
MySQL password expiry
Resetting the password will only solve the problem temporarily. From MySQL 5.7.4 to 5.7.10 (to encourage better security - see MySQL: Password Expiration Policy) the default default_password_lifetime variable value is 360 (1 year-ish). For those versions, if you make no changes to this variable (or to individual user accounts) all passwords expire after 360 days.
So from a script you might get the message: "Your password has expired. To log in you must change it using a client that supports expired passwords."
To stop automatic password expiry, log in as root (mysql -u root -p), then, for clients that automatically connect to the server (e.g. scripts.) change password expiration settings:
ALTER USER 'script'#'localhost' PASSWORD EXPIRE NEVER;
OR you can disable automatic password expiration for all users:
SET GLOBAL default_password_lifetime = 0;
As pointed out by Mertaydin in the comments, to make this permanent add the following line to a my.cnf file MySQL reads on startup, under the [mysqld] group of settings. The location of my.cnf depends on your setup (e.g. Windows, or Homebrew on OS X, or an installer), and whether you want this per-user on Unix or global:
[mysqld]
default_password_lifetime = 0
(There may be other settings here too...)
See the MySQL docs on configuration files.
I went through the same issue recently while installing mysql on mac os x capitan.
I did not find the correct answer here, so adding this answer.
MySql in current versions, generates a temporary password when you install mysql. Use this password to set a new password using the mysqladmin utility as below;
/usr/local/mysql/bin/mysqladmin -u root -p'<your temp password>' password '<your new password>'
Hope it helps you and others.
This worked for me:
ALTER USER 'root'#'localhost' IDENTIFIED BY 'yourpassword','root'#'localhost' PASSWORD EXPIRE NEVER;
Just download MySQL workbench to log in. It will prompt you to change the password immediately and automatically.
On Windows in phpmyadmin look in Variables: default_password_lifetime, and switch it to 0 (instead of 360), enjoy.
Its possible than mySQL take again 360 days, so add in my.ini :
[mysqld]
default_password_lifetime=0
And restart mysql.
start MYSQL in safe mode
mysqld_safe --skip-grant-tables &
Connect to MYSQL server
mysql -u root
run SQL commands to reset password:
use mysql;
SET GLOBAL default_password_lifetime = 0;
SET PASSWORD = PASSWORD('new_password');
Last step, restart your mysql service
i have faced this issue few days ago. For best solution for 5.7 version of MySQL; login your mysql console and alter your password with the following command:
ALTER USER `root`#`localhost` IDENTIFIED BY 'new_password', `root`#`localhost` PASSWORD EXPIRE NEVER;
WARNING: this will allow any user to login
I had to try something else. Since my root password expired and altering was not an option because
Column count of mysql.user is wrong. Expected 45, found 46. The table is probably corrupted
temporarly adding skip-grant-tables under [mysqld] in my.cnf and restarting mysql did the trick
All of these answers are using Linux consoles to access MySQL.
If you are on Windows and are using WAMP, you can start by opening the MySQL console (click WAMP icon->MySQL->MySQL console).
Then it will request you to enter your current password, enter it.
And then type SET PASSWORD = PASSWORD('some_pass');
restart MySQL server with --skip-grant-tables option
And then set a new root password
$ mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET password=PASSWORD("NEWPASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
Now if you need, you can update mysql.user table(field password_expired='N') not to expire the password.
best easy solution:
[PATH MYSQL]/bin/mysql -u root
[Enter password]
SET GLOBAL default_password_lifetime = 0;
and then works fine.
This work for me:
Source: https://www.diariodeunprogramador.net/fallo-al-conectar-mysql-your-password-expired/
Login as root:
mysql -u root -p
and then you deactivate the automatic expiration of passwords of all the users:
SET GLOBAL default_password_lifetime = 0;
On DBeaver, Edit Connection -> Driver Properties -> disable disconnectOnExpiredPasswords:
Reconnect and:
And execute:
SET PASSWORD FOR 'user-name'#'localhost' = PASSWORD('NEW_USER_PASSWORD');
FLUSH PRIVILEGES;
The password expiration is a new feature in MySQL 5.6 or 5.7.
The answer is clear: Use a client which is capable of expired password changing (I think Sequel Pro can do it).
MySQLi library obviously isnt able to change the expired password.
If you have limited access to localhost and you only have a console client, the standard mysql client can do it.
Open MySQL console and type SET PASSWORD = 'your password';
and then press ENTER Key which will set your defined password for user root.
You can only write SET PASSWORD = '';
which will set password as blank for root user.
I did something like this.
UPDATE mysql.user SET authentication_string = PASSWORD(''), password_expired = 'N' WHERE User = 'root' AND Host = 'localhost';
For MySQL 8.0 +, if you get this error,
*Your password has expired. To log in you must change it using a client that
supports expired passwords.*
you need use current user , to open mysql terminal, then use
SET PASSWORD ='123456'; To get a new password 123456 for current user;
Don't use SET PASSWORD = PASSWORD('123456'); This one have been deprecated in MySQL 8.0+;
Just open MySQL Workbench and choose [Instance] Startup/Shutdown and click on start server.
It worked for me
I have MAMP server installed on my Macbook and everything worked fine, until I tried to add a password to the 'root' user of localhost. I selected a password and now whenever I go to localhost:8888/phpmyadmin, the page gives me an error saying:
1045 - Access denied for user 'root'#'localhost' (using password: YES)
It also says that the system tried connecting to MySQL, but MySQL rejected the connection and I have to check my username and password settings.
Why is it acting so weird and how can I get my PHPMyAdmin back to work?
It says I need to check the config.inc.php file, but I can't find that file in the MAMP folder.
the config file should be under:
/Applications/MAMP/bin/phpMyAdmin-X.X.X/config.inc.php
Edit it and verify the username//password used
You can always reset the root password using :
http://www.tech-otaku.com/local-server/resetting-mamp-mysql-root-user-password/
I just installed WAMP server and for creating a new local database, when I clicked phpMyAdmin, i am getting this error,
Error
MySQL said: Documentation
1045 - Access denied for user 'root'#'localhost' (using password: YES)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Can some one please help me??
you are connecting to your local machine. If i am correct wamp does not set any credentials. So you should be fine to login with root and no password.
It's been a while since I have used WAMP (I only use Linux and OSX these days) I seem to remember the following...
In a command prompt enter in the mysql directory :
mysqladmin -u root password NEWPASSWORD
By default a mysql root password is not set yet the phpmyadmin pages are set to to connect with a password.
Dave
If you user has not password connect so. Try do it:
mysql_connect('server','user');
without thrid parameter. If all is right, you are connect to server.
else, if your user has password, you need provide the password correct
mysql_connect('server','user','password_correct');