使用PHP安全地连接到MySQL的最佳方法 [英] Best way to connect to MySQL with PHP securely

查看:57
本文介绍了使用PHP安全地连接到MySQL的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想就你们认为使用PHP连接MySQL数据库的最安全方法提供一些建议.目前,我的操作方式是在所有其他PHP文件的顶部包含实用程序PHP文件.实用程序PHP文件是这样的:

I want some input on what you guys think is the most secure way to connect to a MySQL database using PHP. Currently the way I'm doing it is a utility PHP file that I include in the top of all my other PHP files. The utility PHP file is this:

<?php
    if(!defined('IN_PHP')){
        die("hackerssss");
    }
    $mysql_host = "localhost";
    $mysql_user = "root";
    $mysql_pass = "root";
    $mysql_db = cokertrading;
?>

有什么建议吗?

推荐答案

建议:您可能永远不应该以root用户身份运行;创建另一个帐户,并为其授予您网站所需的最少"特权.

Suggestion: You should probably never be running as root; create another account and give it the 'least' privileges required for your site.

这篇关于使用PHP安全地连接到MySQL的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆