How database password hot changes should be made

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.