dongzhuohan7085 2017-08-17 18:49
浏览 25
已采纳

有没有办法自动调整数据库名称,用户名和密码

I'm currently in the process of making a website using PHP and mysql for the database. I'm pretty much juggling between a local server with WAMP for debugging and sending to the live server. So I was wondering if there was a way to automatically adjust the database name, the username and the password according to the server the website is on. Currently, I'm just doing it manually but I keep forgetting about it and it becomes annoying especially since I'm uploading to the live server several times a day for my friends to test. I've tried using $_SERVER['REMOTE_ADDR'] but for some reason, it doesn't work. Do you guys have any solution or should I just continue doing it manually?

  • 写回答

3条回答 默认 最新

  • duanpin2034 2017-08-17 18:54
    关注

    There's several ways to go about it.

    • Check for server name with gethostname and switch credentials based on that.
    • Create a file on each server with the credentials, with the same name/path. Do not update that file when uploading to the live server.

    If your code allows for environment files such as .env, use that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效