CodeIgniter error mysql_connect(): No such file or directory solution, nosuchfile_PHP tutorial

WBOY
Release: 2016-07-13 10:19:27
Original
1063 people have browsed it

CodeIgniter error mysql_connect(): No such file or directory solution, nosuchfile

First of all, CodeIgniter cannot connect to the database. It always displays a connection error, but there is no error message, making it difficult to debug.

The solution is: add this code at the end of the application/config/database.php file:

Copy code The code is as follows:

echo '
';<br>
print_r($db['default']);<br>
echo '
';

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 '
Connected OK:' ;
die( 'file: ' .__FILE__ . '--> Line: ' .__LINE__);

An error is displayed. The problem is mysql_connect(): No such file or directory error.
Because I have used CI before and did not have this error, I googled and found that it was because MySQL was installed with brew, and PHP was unable to obtain relevant data due to path problems.

Solution:
If you already have /tmp/mysql.sock but not /var/mysql/mysql.sock you should:

Copy code The code is as follows:

cd /var
mkdir mysql
cd mysql
ln -s /tmp/mysql.sock mysql.sock

If you have /var/mysql/mysql.sock but not mysql.sock name:

Copy code The code is as follows:

cd /tmp
ln -s /var/mysql/mysql.sock mysql.sock

No such file or directory I don’t know where the error occurred

Is the file accessed in the program? There is a big possibility that the program uses a relative path when accessing the file, that is, the path to execute the program. When the program is executed, the root path is not what you expect, so access it There is no real document left.
Another possibility is that the root path of the program execution in the debugging state (are you using VC) is different from the root path of the program execution in the release state.

When programming with VC60++, the error message "Cannot open include file: 'graphicsh': No such file or directory" appears?

It is not possible to directly copy a graphics.h under VC, you must have the corresponding .lib. The original poster looks here: code.google.com/p/vcgraphics/downloads/list
Download the VCGraph(V20091123).zip and install it into your VC6. There are instructions inside. Or, there is VC6.7z in it, which has graphics.h configured, and you can use it directly after downloading.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/875393.htmlTechArticleCodeIgniter error mysql_connect(): No such file or directory Solution, nosuchfile First, CodeIgniter cannot connect to the database. It shows a connection error, but there is no error message...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template