Thinkphp,pdo connects to the database, and host is automatically replaced with native ip

class DBAccess extends PDO{
    private $charset;    // 
    public $cacheDir="_cache_$98sdf29@fw!d-sharps4fef/";
    public $prename;
    public $time;
    function __construct($dsn, $user="", $password=""){
        try{
            parent::__construct($dsn, $user, $password);
        }catch(Exception $e){
//            throw new Exception("");
//            throw new Exception($e->getMessage());
//            print_r($user);
            print_r($dsn);
            print_r($e->getMessage());
        }
        $this->time=intval($_SERVER["REQUEST_TIME"]);
    }
}

clipboard.png

host is automatically replaced. What"s going on?

Php
Oct.05,2021

system configuration that you won't change. Take a look at the configuration introduction in the thinkphp manual


configuration file, bro. Who told you to change the source code.


I have encountered a similar situation, setting abc@123.123.123.123 to be accessible, and my local machine is also 123.123.123.123 , but the error message is that abc@456.456.456.456 does not have permission. The difference is that 456.456.456.456 is not the ip of the host where mysql resides. Can only be accessed by changing to abc@% . I never understood why.

Menu