dosi8657 2015-06-15 15:36
浏览 942
已采纳

Moodle数据库连接错误

I am trying to setup moodle and running into a connection problem. See the config below:

<?php  // Moodle configuration file

unset($CFG);
global $CFG;
$CFG = new stdClass();

$CFG->dbtype    = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'gs_vle';
$CFG->dbuser    = 'root';
$CFG->dbpass    = 'root';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
 'dbpersist' => 0,
 'dbport' => '',
 'dbsocket' => '',
);

$CFG->wwwroot   = 'http://localhost/~ryanme/work/vle/';
$CFG->dataroot  = '/Users/ryanme/sites/work/moodledata';
$CFG->admin     = 'admin';

$CFG->directorypermissions = 0777;

require_once(dirname(__FILE__) . '/lib/setup.php');

I am getting a database connection error. See the error below:

Error: Database connection failed

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php

Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in /Users/ryanme/Sites/work/vle/lib/dml/mysqli_native_moodle_database.php on line 79

Things I have done

  • Logged in with the root user via terminal and checked I can see the database with show databases;. This works fine.
  • Checked the settings are correct over and over.
  • Compared the config file to teams setup and it's pretty much the same.
  • Ensured the mysqli module is enabled for PHP. It is.

What can I do to figure out what is causing this database connection error?

  • 写回答

2条回答 默认 最新

  • dongzhou5344 2015-06-15 16:03
    关注

    After more investigation. I found that this was due to "mysql on OS X gets the locations of the required sock file a bit wrong". Once I created the sym links required for the mysql sock file everything worked.

    See linked issue for details.

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

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图