Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用另一个主机名在codeigniter中创建数据库?_Php_Mysql_Database_Codeigniter - Fatal编程技术网

Php 如何使用另一个主机名在codeigniter中创建数据库?

Php 如何使用另一个主机名在codeigniter中创建数据库?,php,mysql,database,codeigniter,Php,Mysql,Database,Codeigniter,我有两个服务器,一个用于文件,另一个用于数据库 我正在尝试创建另一个数据库,但我得到一个错误“拒绝用户访问”username@files_server,但主数据库位于data_服务器上 我的代码是: // create database $this->load->dbforge(); $this->dbforge->create_database("new_database"); 我发现的最常见的事情之一是用户名是用不正确的域名生成的。例如,我注意到在某些环境中,如果

我有两个服务器,一个用于文件,另一个用于数据库

我正在尝试创建另一个数据库,但我得到一个错误“拒绝用户访问”username@files_server,但主数据库位于data_服务器上

我的代码是:

// create database
$this->load->dbforge();

$this->dbforge->create_database("new_database");

我发现的最常见的事情之一是用户名是用不正确的域名生成的。例如,我注意到在某些环境中,如果您有username@%,您将被拒绝访问localhost。您可以通过DB日志挖掘,找出您的系统正在广播的域,并确保在DB中创建的用户与username@your.computers.domain没错

迈克·米勒

CTO PVBid


您遇到的错误是由于未能打开连接,这与您显示的代码无关。这是因为我在此服务器上没有数据库。我正在尝试在另一台服务器上创建新数据库,但在创建新数据库之前,您仍然必须连接到服务器(这就是发生错误的地方)。