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 PH
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';
Just download MySQL workbench to log in. It will prompt you to change the password immediately and automatically.
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;
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.
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.