[PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someone help me out please?
I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I uninstalled both of them and installed again using the following commands: yum install mysql And then apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick And then started the mysql server. I am able to connect to the server from the console my typing mysql -h -u root -p However, when I try to connect to mysql through PHP I get the following errors: PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /export/home/rahul/may/sample.php on line 5 PHP Warning: mysql_query(): A link to the server could not be established in /export/home/rahul/may/sample.php on line 5 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Can someone please help me out? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someone help me out please?
On Sun, May 11, 2008 at 12:30 AM, Rahul <[EMAIL PROTECTED]> wrote: > I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I > uninstalled both of them and installed again using the following commands: > > yum install mysql > > And then > > apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc > php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick > > And then started the mysql server. > > I am able to connect to the server from the console my typing > > mysql -h -u root -p > > However, when I try to connect to mysql through PHP I get the following > errors: > > PHP Warning: mysql_query(): Can't connect to local MySQL server through > socket '/var/lib/mysql/mysql.sock' (2) in /export/home/rahul/may/sample.php > on line 5 > PHP Warning: mysql_query(): A link to the server could not be established > in /export/home/rahul/may/sample.php on line 5 > Can't connect to local MySQL server through socket > '/var/lib/mysql/mysql.sock' (2) > > Can someone please help me out? what is the hostname you are typing at the command line and what is the one you are using when trying to connect from php? when using mysql, you will have to have a separate entry for localhost connections. -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someone help me out please?
Thanks a lot for your reply. I have tried using $host = "localhost"; $db = "dbname"; $table_main = "tablename"; $dbusername = "root"; $dbpass = "passhere"; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); and $host = "mycomputer.webaddress.com"; $db = "dbname"; $table_main = "tablename"; $dbusername = "root"; $dbpass = "passhere"; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); And this mycomputer.webaddress.com works when I use with mysql like this: mysql -h mycomputer.webaddress.com -u root -p Thank You Nathan Nobbe wrote: On Sun, May 11, 2008 at 12:30 AM, Rahul <[EMAIL PROTECTED]> wrote: I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I uninstalled both of them and installed again using the following commands: yum install mysql And then apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick And then started the mysql server. I am able to connect to the server from the console my typing mysql -h -u root -p However, when I try to connect to mysql through PHP I get the following errors: PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /export/home/rahul/may/sample.php on line 5 PHP Warning: mysql_query(): A link to the server could not be established in /export/home/rahul/may/sample.php on line 5 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Can someone please help me out? what is the hostname you are typing at the command line and what is the one you are using when trying to connect from php? when using mysql, you will have to have a separate entry for localhost connections. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someone help me out please?
On Sun, May 11, 2008 at 12:42 AM, Rahul <[EMAIL PROTECTED]> wrote: > Thanks a lot for your reply. > > I have tried using > > $host = "localhost"; > $db = "dbname"; > $table_main = "tablename"; > $dbusername = "root"; > $dbpass = "passhere"; > > mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); > > and > > $host = "mycomputer.webaddress.com"; > $db = "dbname"; > $table_main = "tablename"; > $dbusername = "root"; > $dbpass = "passhere"; > > mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); > > And this mycomputer.webaddress.com works when I use with mysql like this: > > mysql -h mycomputer.webaddress.com -u root -p so, from above (previous post), it looks like the errors youve shown are actually coming from mysql_query(). what is the result of this (using credentials from this post and [mycomputer.webaddress.com])