never forget when setting up a mysql user account
Someday ago i was working 2 facebook projects. When I was working on the 2nd facebook project, I just copied the first project architecture. Then I setup the mysql user account for the second project. As the two projects are similar, I thought to remain the username for mysql same for the 2 projects, but when I did that I created a great mistake that I’m describing here.
When I setup my 1st project’s database I use
mysql> GRANT ALL ON fb1.* TO 'simpleuser'@'localhost' IDENTIFIED BY 'simpass123';
Then I used ‘simpleuser’ as user and ‘simpass123’ as password for my first project. And after made it live app, I was working in the second project.
Then I setup mysql account for the same user ‘simpleuser’ for another db.
mysql> GRANT ALL ON fb2.* TO 'simpleuser'@'localhost' IDENTIFIED BY 'abcpass123';
After made it production server, around 30 min my first project remain down, as that project couldn’t connect mysql database. WHY ? What mistake I did?
The mistake was, I used same username but at the second time I changed the password, that changed the existing acccount ‘simpleuser’ password. So, in first project database couldn’t be connect.
So never forget: “IDENTIFIED BY ‘difpassowrd’ should be avoided when you’ll use GRANT statement and the same user for different database “. Otherwise as it’ll change user’s password, other projects may suffer.