Rails 和 MySQL——设置 root 密码的困境
我现在面临着一个困境 - 我知道在没有密码的情况下保留我的 MySQL 根帐户是不安全的,但我觉得在处理有许多用户的大型项目时不断修改 会是一个很大的麻烦database.yml
文件的开发信息,以反映我每次从 git 拉取时的个人 root 帐户密码,然后在推送之前不断将其切换回来。有没有一种方法可以为 root 设置密码,但每次我在其他人处理完之后从 git 存储库中拉取时,都不必继续修改 database.yml 文件的开发区域?
I am kind of facing a dilemma right now - I know it is insecure to leave my root MySQL account without a password, but I feel like it would be a big hassle when working on big projects with many users to keep modifying the database.yml
file's development info to reflect my personal root account password every time I pull from git and then to keep switching it back before pushing. Is there a way to have a password for root and yet not have to keep modifying the database.yml file's development area every time I pull from the git repo after others have worked on it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个模板database.yml并将其命名为不同的名称,例如database.yml.template或其他名称。然后让 git 忽略实际的 database.yml 文件,您现在可以根据自己的个人设置配置该文件。真正的配置不会被 git pull 触及,也不会被意外推送到源存储库。
Create a template database.yml and call it something different, like database.yml.template or something. Then have git ignore the actual database.yml file which you now can configure for your own personal settings. The real configuration will not be touched by git pull and will not be accidentally pushed to the source repo either.
为什么不想将其添加到
.gitignore
中?因此,存储库中将存在database.yml
的冻结版本。Why don't you want to add it to
.gitignore
? So it there will be frozen version ofdatabase.yml
in the repo.