How should I hot modify the Database Password?

Source: Internet
Author: User
I don't know if you can understand the phrase "Hot password change" in the database. It means hot plugging (I don't know how to describe it... in other words, when the website is running, changing the database password will not cause password errors or other errors. My blog (Typecho) has a low access volume... I wonder if you can understand it. Hot modification of Database PasswordThis phrase means Hot pluggingOf Hot(I don't know how to describe it.), that is Change the Database Password while the website is running, without errors such as password errors.

My blog (Typecho) has a very low access volume. If you change the database password, you don't have to worry about an error, because in just over a dozen seconds (Modification on the Host Control Panel) the probability of human access is quite low. I guess this is the case for many people/many small websites. If the traffic volume is a little large, it can be done in the dead of night.

So the question is: How should a website with a large traffic volume (such as SF or something) Hot change the Database Password?

One of the solutions I suddenly came up with when I was writing this question was

In the configuration file, write the Database Password as an array and save two or more passwords. IfPassword 1If an error is reportedPassword 2.
Before changing the password, change the password that is invalid in the configuration file to the new password to be modified, and then change the Database Password. In this way, the new password and old password can coexist for seamless switching.

However, I feel that the efficiency will be reduced. When I do not change the password at ordinary times, I have to make a judgment every time I connect to the database...

P.S. Don't be limited to the solution I think of. Hello (I feel that if I leave a solution for each question, many people will follow my ideas to improve it). In this regardNo experienceYes !!

Reply content:

I wonder if you can understand it.Hot modification of Database PasswordThis phrase meansHot pluggingOfHot(I don't know how to describe it.), that isChange the Database Password while the website is running, without errors such as password errors.

My blog (Typecho) has a very low access volume. If you change the database password, you don't have to worry about an error, because in just over a dozen seconds (Modification on the Host Control Panel) the probability of human access is quite low. I guess this is the case for many people/many small websites. If the traffic volume is a little large, it can be done in the dead of night.

So the question is: How should a website with a large traffic volume (such as SF or something) Hot change the Database Password?

One of the solutions I suddenly came up with when I was writing this question was

In the configuration file, write the Database Password as an array and save two or more passwords. IfPassword 1If an error is reportedPassword 2.
Before changing the password, change the password that is invalid in the configuration file to the new password to be modified, and then change the Database Password. In this way, the new password and old password can coexist for seamless switching.

However, I feel that the efficiency will be reduced. When I do not change the password at ordinary times, I have to make a judgment every time I connect to the database...

P.S. Don't be limited to the solution I think of. Hello (I feel that if I leave a solution for each question, many people will follow my ideas to improve it). In this regardNo experienceYes !!

Well, let's look at a small chestnut. The password expiration problem is handled by exception. To put it bluntly, you can try again. When the password configuration is re-issued, the new connection will use the new configuration, and the old connection will be destroyed after an exception occurs, because it is a connection managed by the connection pool, so there is no need to create a new one. It is much more lazy and simple:>.

In fact, in the Mysql protocol, the password becomes invalid after the connection is established.ERROR 1820(In fact, the user is invalid.) You can useSET PASSWORDMake changes. Therefore, the subject is worried about not having to worry about it. Wait for an exception to be thrown and try again by changing the password of the current connection in the exception.

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.