在将CI 2.x中的项目迁移到3.x后,在使用mongo db的地方显示以下错误,这在codeigniter版本2中可以正常工作
消息:无法解析MongoDB URI:'mongodb://'。无效的主机 URI中的字符串。
Db配置
// Generally will be localhost if you're querying from the machine that Mongo is installed on
$config['mongo_host'] = "localhost";
//$config['mongo_host'] = "xxxxxxxxx.compute.amazonaws.com";
// Generally will be 27017 unless you've configured Mongo otherwise
$config['mongo_port'] = 27017;
// The database you want to work from (required)
$config['mongo_db'] = "test_p1";
// Leave blank if Mongo is not running in auth mode
$config['mongo_user'] = "";
$config['mongo_pass'] = "";
// Persistant connections
$config['mongo_persist'] = TRUE;
$config['mongo_persist_key'] = 'ci_mongo_persist';
// Get results as an object instead of an array
$config['mongo_return'] = 'array'; // Set to object
// When you run an insert/update/delete how sure do you want to be that the database has received the query?
// safe = the database has receieved and executed the query
// fysnc = as above + the change has been committed to harddisk <- NOTE: will introduce a performance penalty
$config['mongo_query_safety'] = 'safe';
// Supress connection error password display
$config['mongo_supress_connect_error'] = TRUE;
// If you are having problems connecting try changing this to TRUE
$config['host_db_flag'] = FALSE;
答案 0 :(得分:1)
您可能会忘记在本地计算机上设置数据库。