Codeigniter出现Unable to connect to your database server using the provided settings错误解决办法
2012-04-12 14:04
846 查看
症状:
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__);
添加代码后再次访问网站,可以看到调试信息,并在最后给出解决的建议。
解决办法:
(根据问题的不同,方法不同)调试信息提示数据库被锁,因此需要先解锁。执行 mysqladmin flush-hosts
即可。
参考:http://stackoverflow.com/questions/7254049/codeigniter-unable-to-connect-to-your-database-server-using-the-provided-settin
相关文章推荐
- 查找网站搬迁错误Unable to connect to your database server using the provided settings
- Codeigniter出现Unable to load the requested class: zebra_pagination错误解决办法
- 出现 check the manual that corresponds to your MySQL server version 的错误解决
- Docker出现Cannot connect to the Docker daemon. Is the docker daemon running on this host错误解决办法
- Mint17.3/Ubuntu14.04出现failed to start the X server ...错误的解决办法
- mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication错误解决办法
- 关于 JDeveloper 出现 unable to create an instance of the java virtual machine 错误的解决办法
- Vmware vSphere 出现 unable to connect to the mks问题的解决办法
- Linux上 Can't connect to X11 window server using XX as the value of the DISPLAY 错误解决方法
- Linux上mysql登陆错误解决办法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/
- mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication解决办法
- 服务器Tomcat启动 访问出现Can't connect to X11 window server using 'localhost:0.0' as the value of the DISPLA
- Codeigniter上传图片出现“You did not select a file to upload”错误解决办法
- Unable to connect to database server:specified database is invalid 错误修复方法
- scp 出现错误ssh: connect to host 9.123.159.41 port 22:connection refused的解决办法
- 在Yii下进行模块化(module)编程以及出现Unable to resolve the request的解决办法
- 导入android项目出现:出现Unable to resolve target 'android-8'错误及其他的一些解决办法
- ARCSDE直连Oracle时出现错误Failed to connect to the specified server. Underlying DBMS error[ORA-12154: TNS:could not resolve the connect identifier specified. No extended error]
- Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable解决方法