Codeigniter 报错 Unable to connect to your database server using the provided settings
来源:互联网 发布:男士 爽肤水 知乎 混合 编辑:程序博客网 时间:2024/05/19 00:17
最新在用php开发我的个人网页,刚接触,效率很慢,各种问题都需要学习.比如如何获得当前时间这么简单的问题也要谷歌一下.
在使用Codeigniter操作数据库的时候报错Unable to connect to your database server using the provided settings.在网上找了一下,可能会有很多情况出现这个问题,先要问题的真正原因.找到一个打印详细原因的办法.在config/database.php的后面添加下面的代码:
echo '<pre>'; print_r($db['default']);echo '</pre>';echo 'Trying to connect to database: ' .$db['default']['database'];$dbh=mysql_connect($db['default']['hostname'],$db['default']['username'],$db['default']['password'])or die('Cannot connect to the database because: ' . mysql_error());mysql_select_db ($db['default']['database']);echo '<br /> Connected OK:' ;die( 'file: ' .__FILE__ . '--> Line: ' .__LINE__);
再次访问的时候就出打印出详细错误:No such file or directory!
找到了一篇文章:http://hoarn.blog.51cto.com/1642678/1229555
这里记录一下:
首先确定是
mysql_connect()
和mysql_pconnect()
的问题,故障现象就是函数返回空,而mysql_error()
返回“No such file or directory”。写个phpinfo页面,找到
mysql.default_socket
、mysqli.default_socket
、pdo_mysql.default_socket
。启动mysql,执行命令 STATUS; 记下UNIX socket的值。
如果2和3的值不一样,则打开php.ini(可以从phpinfo页面中找到php.ini的位置,默认是
/private/etc/php.ini
),将2中提到的三个配置项的值改成3的值。重启apache。
0 0
- Codeigniter 报错 Unable to connect to your database server using the provided settings
- 查找网站搬迁错误Unable to connect to your database server using the provided settings
- Genymotion报错:unable to connect to the virtual device
- MySQL Workbench 报错 Cannot connect to Database Server
- C028: "Unable to Connect to the Siebel Gateway Name Server
- Unable to connect to the remote server 问题
- Using the data layer API to query your Kentico database
- apache 报apache 报 The server is temporarily unable to service your request due to maintenance downtim
- Unable to connect to database server:specified database is invalid 错误修复方法
- dubbo-provider启动报错:Unable to connect to zookeeper server within timeout: 5000
- php 连sql server 2008R2 报错 mssql_connect() [function.mssql-connect]: Unable to connect to server
- 解决Genymotion启动报错:“unable to connect to the virtual device
- vSphere报错--unable to connect to the MKS:Internal error
- Visual Studio 2010--报错mysql:Unable to connect to any of the specified MySQL hosts
- TSM错误:ANR1820E The server could not connect to the database manager by using TCP/IP port 51500.
- PB报unable to load the requested database interface错误
- unable to connect to converter enterprise server
- hive----MetaException(message:Could not connect to meta store using any of the URIs provided. Most r
- Learn Java for Android Development Second Edition 笔记(一)
- Ubuntu 删除缓存
- URAL 1517 Freedom of Choice
- Leetcode - string - Reverse Words in a String
- NYOJ36&&南阳理工oj_36(动态规划)
- Codeigniter 报错 Unable to connect to your database server using the provided settings
- Linux系统里如何彻底的清空屏幕?
- 服务器端口大全
- 软件设计原则
- cocos2dx 定时器(schedule)的使用及Label类的使用
- DM642图像处理程序的主要结构
- 惊恐,无处可逃!
- 几个表单操作(个人笔记)
- STL generate_n 和 generate 用法