I don't know if you can read it.
数据库密码热修改
The meaning of this phrase is that
热拔插
Of
热
(I don't know how to describe it.) ), which means
在网站在运行的状态下修改数据库密码而不会出现密码错误之类的报错
My blog (typecho) access is very low and low, to modify the database password without considering the error, because in that short more than 10 seconds (modified in the Host Control Panel) the probability of someone accessing is quite low. I guess a lot of people/a lot of small sites are like this, a little bit more traffic can be done in the dead of night.
So here's the question: How do you make a hot change to a database password for a website that has a large number of visits (such as SF)?
One of the solutions that suddenly occurred to me when I wrote this question was
In the configuration file, the database password is written into an array, save two or more passwords, each connection if the 密码1
error is used 密码2
to connect.
Before you change the password, change the password that is not valid in the configuration file to the new password that you want to modify, and then modify the database password so that the old and new passwords can coexist for seamless switching.
But feel this efficiency will not be reduced, in peacetime no change password, every connection to the database to make a judgment ...
P.s. Don't be confined to the plan I'm thinking of. Hello (feel every question if I leave a plan, many people will follow my ideas to improve), I have no experience in this AH Hello!!
Reply content:
I do not know if you can understand the 数据库密码热修改
meaning of this phrase, that is 热拔插
热
(I do not know how to describe ah ...) ), which means在网站在运行的状态下修改数据库密码而不会出现密码错误之类的报错
My blog (typecho) access is very low and low, to modify the database password without considering the error, because in that short more than 10 seconds (modified in the Host Control Panel) the probability of someone accessing is quite low. I guess a lot of people/a lot of small sites are like this, a little bit more traffic can be done in the dead of night.
So here's the question: How do you make a hot change to a database password for a website that has a large number of visits (such as SF)?
One of the solutions that suddenly occurred to me when I wrote this question was
In the configuration file, the database password is written into an array, save two or more passwords, each connection if the 密码1
error is used 密码2
to connect.
Before you change the password, change the password that is not valid in the configuration file to the new password that you want to modify, and then modify the database password so that the old and new passwords can coexist for seamless switching.
But feel this efficiency will not be reduced, in peacetime no change password, every connection to the database to make a judgment ...
P.s. Don't be confined to the plan I'm thinking of. Hello (feel every question if I leave a plan, many people will follow my ideas to improve), I have no experience in this AH Hello!!
Well, give me a little chestnut before. The password expiration issue is handled by an exception, which is simply a retry. When the password configuration is re-issued, the new connection will use the new configuration, and the old connection will be destroyed after the exception, because it is a connection pool management connection, so nothing to do the new one is, more lazy more simple:>.
In fact, in the Mysql protocol, the password fails after the connection is established ERROR 1820
(in fact, the user is invalid), can be used SET PASSWORD
to make changes. Therefore, the main worry is not necessary, waiting to throw the exception, in the exception to handle the replacement of the current connection password retry.