vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi my initial forays into MySQL and PhP aren't going well, and I think well if I'm stumped _this_ early in the game... I use the following file on my webserver, which I've named 'test.php'.. <?php $dbhost='localhost'; $dbname='mydb'; $dubuser='user'; $dbpass='GTEGF65'; $conn = mysql_connect($dbhost, $dubuser, $dbpass) or die ('Cannot connect to DB!!'); ?> The result when I load that? Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /usr/local/www/data/.php/test.php on line 8 Cannot connect to DB!! The paths etc. have been changed, of course. Now if I do ... % mysql -A -u user mydb -pGTEGF65 .... I get... Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 22 Server version: 5.0.41 MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> In other words, it works. So why can't I connect from within a php file? The password is _identical_ (I even copied and pasted it to make sure). This is annoying .. is there a typo that I can't see, or is it something, like some sort of 'rite of passage' that all newbies have to go through?? Help !! D. -- des |
| |||
| desmond wrote: > Hi > my initial forays into MySQL and PhP aren't going well, and I think > well if I'm stumped _this_ early in the game... > > I use the following file on my webserver, which I've named 'test.php'.. Perhaps you don't have MySQL listening on a TCP/IP port, which is what PHP is expecting. Cheers, Nicholas Sherlock |
| |||
| Nicholas Sherlock <N.sherlock@gmail.com> wrote: > desmond wrote: >> Hi >> my initial forays into MySQL and PhP aren't going well, and I think >> well if I'm stumped _this_ early in the game... >> >> I use the following file on my webserver, which I've named 'test.php'.. > > Perhaps you don't have MySQL listening on a TCP/IP port, which is what > PHP is expecting. Interesting... the webserver is on localhost.. A quick search of the 5.1 manual, reveals too many 'hits' for me to find 'TCP/IP' ... can you tell me how to determine if MySQL _is_ listening on a TCP/IP port ..? Thanks |
| |||
| desmond wrote: > Hi > my initial forays into MySQL and PhP aren't going well, and I think > well if I'm stumped _this_ early in the game... > > I use the following file on my webserver, which I've named 'test.php'.. > > <?php > > $dbhost='localhost'; > $dbname='mydb'; > $dubuser='user'; > $dbpass='GTEGF65'; > > $conn = mysql_connect($dbhost, $dubuser, $dbpass) > or die ('Cannot connect to DB!!'); > ?> > > The result when I load that? > > Warning: mysql_connect() [function.mysql-connect]: Can't connect to local > MySQL server through socket '/var/mysql/mysql.sock' (2) in > /usr/local/www/data/.php/test.php on line 8 > Cannot connect to DB!! > > The paths etc. have been changed, of course. > > Now if I do ... > > % mysql -A -u user mydb -pGTEGF65 > > ... I get... > > Welcome to the MySQL monitor. Commands end with ; or \g. > Your MySQL connection id is 22 > Server version: 5.0.41 MySQL Community Server (GPL) > > Type 'help;' or '\h' for help. Type '\c' to clear the buffer. > > mysql> > > In other words, it works. So why can't I connect from within a php file? > The password is _identical_ (I even copied and pasted it to make sure). > This is annoying .. is there a typo that I can't see, or is it something, > like some sort of 'rite of passage' that all newbies have to go through?? > > Help !! > > D. Do you actually have your mysql socket at /var/mysql/mysql.sock? If not, where is it? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| |||
| Jerry Stuckle <jstucklex@attglobal.net> wrote: >> In other words, it works. So why can't I connect from within a php file? >> The password is _identical_ (I even copied and pasted it to make sure). >> This is annoying .. is there a typo that I can't see, or is it something, >> like some sort of 'rite of passage' that all newbies have to go through?? >> >> Help !! >> >> D. > > Do you actually have your mysql socket at /var/mysql/mysql.sock? If > not, where is it? > /private/tmp/mysql.sock (it's a Mac). D. |
| |||
| desmond wrote: > Jerry Stuckle <jstucklex@attglobal.net> wrote: >>> In other words, it works. So why can't I connect from within a php file? >>> The password is _identical_ (I even copied and pasted it to make sure). >>> This is annoying .. is there a typo that I can't see, or is it something, >>> like some sort of 'rite of passage' that all newbies have to go through?? >>> >>> Help !! >>> >>> D. >> Do you actually have your mysql socket at /var/mysql/mysql.sock? If >> not, where is it? >> > /private/tmp/mysql.sock > > (it's a Mac). > > D. Then you need to specify it in your client section of your my.cnf (or php.ini file). Right now PHP is using the default. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| |||
| Jerry Stuckle <jstucklex@attglobal.net> wrote: > desmond wrote: >> Jerry Stuckle <jstucklex@attglobal.net> wrote: >>>> In other words, it works. So why can't I connect from within a php file? >>>> The password is _identical_ (I even copied and pasted it to make sure). >>>> This is annoying .. is there a typo that I can't see, or is it something, >>>> like some sort of 'rite of passage' that all newbies have to go through?? >>>> >>>> Help !! >>>> >>>> D. >>> Do you actually have your mysql socket at /var/mysql/mysql.sock? If >>> not, where is it? >>> >> /private/tmp/mysql.sock >> >> (it's a Mac). >> >> D. > > Then you need to specify it in your client section of your my.cnf (or > php.ini file). Right now PHP is using the default. /private/etc/my.cnf now looks like this... [mysqld] safe-user-create socket=/private/tmp/mysql.sock [client] port=3306 socket=/private/tmp/mysql.sock Same error. D. |
| |||
| On Sun, 24 Jun 2007 15:19:35 +0200, desmond <desmond@zeouane.org> wrote: >Jerry Stuckle <jstucklex@attglobal.net> wrote: >> desmond wrote: >>> Jerry Stuckle <jstucklex@attglobal.net> wrote: >>>>> In other words, it works. So why can't I connect from within a php file? >>>>> The password is _identical_ (I even copied and pasted it to make sure). >>>>> This is annoying .. is there a typo that I can't see, or is it something, >>>>> like some sort of 'rite of passage' that all newbies have to go through?? >>>>> >>>>> Help !! >>>>> >>>>> D. >>>> Do you actually have your mysql socket at /var/mysql/mysql.sock? If >>>> not, where is it? >>>> >>> /private/tmp/mysql.sock >>> >>> (it's a Mac). >>> >>> D. >> >> Then you need to specify it in your client section of your my.cnf (or >> php.ini file). Right now PHP is using the default. > >/private/etc/my.cnf now looks like this... > >[mysqld] >safe-user-create >socket=/private/tmp/mysql.sock > >[client] >port=3306 >socket=/private/tmp/mysql.sock > >Same error. > >D. That's the MySQL config. What's in your php.ini ? ; Default port number for mysql_connect(). If unset, mysql_connect() will use ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the ; compile-time value defined MYSQL_PORT (in that order). Win32 will only look ; at MYSQL_PORT. mysql.default_port = ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = -- ( Kees ) c[_] You only live twice, Or so it seems. One life for yourself, And one for your dreams. You drift through the years And life seems tame, Till one dream appears, And love is its name. (#230) |
| |||
| desmond wrote: > Jerry Stuckle <jstucklex@attglobal.net> wrote: >> desmond wrote: >>> Jerry Stuckle <jstucklex@attglobal.net> wrote: >>>>> In other words, it works. So why can't I connect from within a php file? >>>>> The password is _identical_ (I even copied and pasted it to make sure). >>>>> This is annoying .. is there a typo that I can't see, or is it something, >>>>> like some sort of 'rite of passage' that all newbies have to go through?? >>>>> >>>>> Help !! >>>>> >>>>> D. >>>> Do you actually have your mysql socket at /var/mysql/mysql.sock? If >>>> not, where is it? >>>> >>> /private/tmp/mysql.sock >>> >>> (it's a Mac). >>> >>> D. >> Then you need to specify it in your client section of your my.cnf (or >> php.ini file). Right now PHP is using the default. > > /private/etc/my.cnf now looks like this... > > [mysqld] > safe-user-create > socket=/private/tmp/mysql.sock > > [client] > port=3306 > socket=/private/tmp/mysql.sock > > Same error. > > D. Did you stop and start (not just reload) MySQL and Apache? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| ||||
| Jerry Stuckle <jstucklex@attglobal.net> wrote: > desmond wrote: >> Jerry Stuckle <jstucklex@attglobal.net> wrote: >>> desmond wrote: >>>> Jerry Stuckle <jstucklex@attglobal.net> wrote: >>>>>> In other words, it works. So why can't I connect from within a php file? >>>>>> The password is _identical_ (I even copied and pasted it to make sure). >>>>>> This is annoying .. is there a typo that I can't see, or is it something, >>>>>> like some sort of 'rite of passage' that all newbies have to go through?? >>>>>> >>>>>> Help !! >>>>>> >>>>>> D. >>>>> Do you actually have your mysql socket at /var/mysql/mysql.sock? If >>>>> not, where is it? >>>>> >>>> /private/tmp/mysql.sock >>>> >>>> (it's a Mac). >>>> >>>> D. >>> Then you need to specify it in your client section of your my.cnf (or >>> php.ini file). Right now PHP is using the default. >> >> /private/etc/my.cnf now looks like this... >> >> [mysqld] >> safe-user-create >> socket=/private/tmp/mysql.sock >> >> [client] >> port=3306 >> socket=/private/tmp/mysql.sock >> >> Same error. >> >> D. > > Did you stop and start (not just reload) MySQL and Apache? Yes. |