开发者

CakePHP: What to use for MySQL users & permissions?

开发者 https://www.devze.com 2022-12-28 12:18 出处:网络
I\'m getting ready to deploy a CakePHP site for the first time. I\'m using the site with a MySQL database, and I\'m still a little unclear about the proper use of users & permissions for MySQL --

I'm getting ready to deploy a CakePHP site for the first time. I'm using the site with a MySQL database, and I'm still a little unclear about the proper use of users & permissions for MySQL -- I'm talking about the "login" and "password" fields that appear in app/config/database.php. During development, I've been using 'root' and 'root' -- but I'm pretty sure that can't be a good idea. So my question is: what are the best practices for 开发者_如何学运维assigning a MySQL user to a CakePHP app, and what MySQL privileges should be assigned to it?


The least amount of permissions possible, so INSERT, SELECT, UPDATE, and DELETE on the database in question, certainly not CREATE/DROP privileges. Best practice: make the password hard to guess. You're hardcoding it anyways, there's no reason not to make it a terrible monster of a password. Also, ensure it can only be accessed by localhost or your IP.

GRANT INSERT, SELECT, DELETE, UPDATE ON mydb.* to 'myuser'@'localhost' IDENTIFIED BY 'monsterpassword'
0

精彩评论

暂无评论...
验证码 换一张
取 消