Re: PHP script cannot connect MySQL server

2004-03-23 Thread Sami Maisniemi
On Tuesday 23 March 2004 02:15, [EMAIL PROTECTED] wrote:
  tcp0  0 *:3307  *:*
  LISTEN
 
 It seems that the correct socket is used. Here is the output:
 
 unix  2  [ ACC ] STREAM LISTENING 3303   private/relay
 unix  2  [ ACC ] STREAM LISTENING 3307   public/showq

  Looks like 3307 is indeed open, so you may want to modify your
 mysql_connect to use localhost:3307 - since that is likely to be the
 port mysqld is using based upon this output.  The default is usually
 3306, so if you do not include the :3307 port reference you may very
 well not be able to connect.
 Brad Eacker ([EMAIL PROTECTED])

I tried to connect to socket #3307 as follows:

$link = mysql_connect(localhost:3307, root, passwd);

but without any changes. Hmmm ... I did not expect this to be so hard.

Regards Sami


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-23 Thread jeffrey_n_Dyke


n Tuesday 23 March 2004 02:15, [EMAIL PROTECTED] wrote:
  tcp0  0 *:3307  *:*
  LISTEN
 
 It seems that the correct socket is used. Here is the output:
 
 unix  2  [ ACC ] STREAM LISTENING 3303   private/relay
 unix  2  [ ACC ] STREAM LISTENING 3307   public/showq

  Looks like 3307 is indeed open, so you may want to modify your
 mysql_connect to use localhost:3307 - since that is likely to be the
 port mysqld is using based upon this output.  The default is usually
 3306, so if you do not include the :3307 port reference you may very
 well not be able to connect.
 Brad Eacker ([EMAIL PROTECTED])

I tried to connect to socket #3307 as follows:

$link = mysql_connect(localhost:3307, root, passwd);

but without any changes. Hmmm ... I did not expect this to be so hard.

--
I've lost track of this thread so sorry if this is no longer valid...
Have you read http://www.mysql.com/doc/en/Multiple_servers.html?

Its not as simple as just specying a port, i don't think, you'll need to
make sure mysql in using a different socket file on start up if you want to
connect to an additional/different port.  I set two up once..one on 3.x and
one on 4.0x, and specifying the socket file/listen port was the magic combo
for me.(2 years ago now, so my memory may not be serving me well)

Does this already work on 3306 for you?

Again, sorry if this is no longer valid or redundant.

Jeff
___

Regards Sami


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]







-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-23 Thread beacker
Sami Maisniemi [EMAIL PROTECTED] writes:
 It seems that the correct socket is used. Here is the output:
 
 unix  2  [ ACC ] STREAM LISTENING 3303   private/relay
 unix  2  [ ACC ] STREAM LISTENING 3307   public/showq
...
I tried to connect to socket #3307 as follows:

$link = mysql_connect(localhost:3307, root, passwd);

Sami,
 Could you verify that you can connect with mysql via

mysql -h localhost -P 3307

If we have identified the proper host/port you should receive the standard
'mysql ' prompt.
   Brad Eacker ([EMAIL PROTECTED])



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread Rick Emery
/var/lib/mysql/mysql.sock is created when the mysql server starts.  It disappears when 
mysql shuts
down.

Did you provide access to the databases as root?  Is there a password associated with 
access?  For
instance, how do you statr mysql from the command line:  mysql -u root -ppassword 
mydatabase

rick
People will forget what you said. People will forget what you did.
But people will never forget how you made them feel.
- Original Message - 
From: Sami Maisniemi [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 22, 2004 12:25 PM
Subject: PHP script cannot connect MySQL server


I finally managed to install MySQL succesfully. I created a simple DB with two
different tables. I also created a simple PHP script to list all DBs and
tables.

However, it seems that the PHP script cannot access MySQL server, because the
following error message is displayed:

Warning: mysql_connect(): Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2) in /srv/www/htdocs/sqltest.php on line 4

Warning: mysql_list_dbs(): supplied argument is not a valid MySQL-Link
resource in /srv/www/htdocs/sqltest.php on line 5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /srv/www/htdocs/sqltest.php on line 6

Any idea what might be wrong? There is no file 'mysql.sock' in '/var/lib/
mysql'. The PHP script is as follows:

htmlbody

?php
$link_id = mysql_connect(localhost, root);
$result = mysql_list_dbs($link_id);
$num_rows = mysql_num_rows($result);

while ($db_data = mysql_fetch_row($result)) {
  echo $db_data[0]. BR;
  $result2 = mysql_list_tables($db_data[0]);
  $num_rows2 = mysql_num_rows($result2);
  while ($table_data = mysql_fetch_row($result2)) {
echo -- . $table_data[0]. BR;
  }
  echo == $num_rows2 table(s) in  . $db_data[0] . BR;
}
?

/body/html

Regards Sami


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread jeffrey_n_Dyke



I finally managed to install MySQL succesfully. I created a simple DB with
two
different tables. I also created a simple PHP script to list all DBs and
tables.

However, it seems that the PHP script cannot access MySQL server, because
the
following error message is displayed:
_
This means that your server is not up, most likely.  Can you connect from
the command line?  try running
ps  -efc | grep mys

do you see an entry for mysqld?

How did you start your server?

HTH
Jeff



Warning: mysql_connect(): Can't connect to local MySQL server through
socket
'/var/lib/mysql/mysql.sock' (2) in /srv/www/htdocs/sqltest.php on line 4

Warning: mysql_list_dbs(): supplied argument is not a valid MySQL-Link
resource in /srv/www/htdocs/sqltest.php on line 5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /srv/www/htdocs/sqltest.php on line 6

Any idea what might be wrong? There is no file 'mysql.sock' in '/var/lib/
mysql'. The PHP script is as follows:

htmlbody

?php
$link_id = mysql_connect(localhost, root);
$result = mysql_list_dbs($link_id);
$num_rows = mysql_num_rows($result);

while ($db_data = mysql_fetch_row($result)) {
  echo $db_data[0]. BR;
  $result2 = mysql_list_tables($db_data[0]);
  $num_rows2 = mysql_num_rows($result2);
  while ($table_data = mysql_fetch_row($result2)) {
echo -- . $table_data[0]. BR;
  }
  echo == $num_rows2 table(s) in  . $db_data[0] . BR;
}
?

/body/html

Regards Sami


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]







-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread beacker
I finally managed to install MySQL succesfully. I created a simple DB with 
two
different tables. I also created a simple PHP script to list all DBs and 
tables.

However, it seems that the PHP script cannot access MySQL server, because the 
following error message is displayed:

Warning: mysql_connect(): Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (2) in /srv/www/htdocs/sqltest.php on line 4

This error could result from a number of possible problems.  First off I
would check to make sure the mysqld is running and attaching to the default
socket (3306).  If you have it set up otherwise, you will likely need the
connect to contain the ':3307' socket adjustment to the name of the host
being sought.  I have validated that the rest of your logic is correct
once the connection is established.
 Brad Eacker ([EMAIL PROTECTED])



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread Sami Maisniemi
On Monday 22 March 2004 20:36, [EMAIL PROTECTED] wrote:
 This means that your server is not up, most likely.  Can you connect from
 the command line?  try running
 ps  -efc | grep mys

 do you see an entry for mysqld?

It seems that the server is up and running, because I am able to see multiple 
processes referring to MySQL.

 How did you start your server?

I have some scripts that start MySQL server automatically during login.

Regards Sami


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread Sami Maisniemi
On Monday 22 March 2004 21:45, [EMAIL PROTECTED] wrote:
 This error could result from a number of possible problems.  First off I
 would check to make sure the mysqld is running and attaching to the default
 socket (3306).  If you have it set up otherwise, you will likely need the
 connect to contain the ':3307' socket adjustment to the name of the host
 being sought.  I have validated that the rest of your logic is correct
 once the connection is established.

It seems that mysqld is up and running (view the results below), but could you 
specify how to check the socket, please?

Regards Sami

dhcppc9:/home/smaisnie # ps  -efc | grep mys
root  1211 1 -21 19:45 ?00:00:00 /bin/sh ./bin/mysqld_safe 
--datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/dhcppc9.pid
mysql 1240  1211 -24 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1288  1240 -24 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1289  1288 -20 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1290  1288 -23 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1291  1288 -23 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1292  1288 -20 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1294  1288 -24 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1295  1288 -24 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1296  1288 -24 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
mysql 1297  1288 -24 19:45 ?00:00:00 /usr/local/mysql/bin/
mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/
local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/
local/mysql/data/dhcppc9.pid --skip-locking
root  2206  1829 -21 21:57 pts/100:00:00 grep mys


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread Sami Maisniemi
 Did you provide access to the databases as root?  Is there a password
 associated with access?  For instance, how do you statr mysql from the
 command line:  mysql -u root -ppassword mydatabase

I think I am using root access, but should I create another user name for 
MySQL? On the command line, I start MySQL by typing just 'MySQL'. How can I 
view the user?

I tried to create a root password and I added the password to the PHP script, 
but I did not see any impact.

Regards Sami


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread B. van Ouwerkerk
At 22:00 22-03-2004 +0200, Sami Maisniemi wrote:
 Did you provide access to the databases as root?  Is there a password
 associated with access?  For instance, how do you statr mysql from the
 command line:  mysql -u root -ppassword mydatabase
I think I am using root access, but should I create another user name for
MySQL? On the command line, I start MySQL by typing just 'MySQL'. How can I
view the user?
I tried to create a root password and I added the password to the PHP script,
but I did not see any impact.
You may want to look at some tutorials at php.net and devshed.com first.

They should get you started.

B. 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: PHP script cannot connect MySQL server

2004-03-22 Thread beacker
It seems that mysqld is up and running (view the results below), but could 
you
specify how to check the socket, please?

Based on your ps information, the socket will likely be in the
/usr/local/mysql/data/my.cnf file under the [mysqld] area.  Another way
to tell if there is a socket open for the server would be to use

netstat -a | grep 330

Which would show a line similar to this:

tcp0  0 *:3307  *:* LISTEN 


with the port I'm using {3307} showing up as currently in use, tcp
protocol with a listener {LISTEN} connected to the socket.  Hopefully
the port specified in the my.cnf will show on the netstat output as
described above.
   Brad Eacker ([EMAIL PROTECTED])



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread beacker
Sami Maisniemi writes:
I think I am using root access, but should I create another user name for 
MySQL? On the command line, I start MySQL by typing just 'MySQL'. How can I 
view the user?

from the mysql program:

mysql use mysql
mysql select User,Host,Password,Select_priv from user;

which will show basic access capabilities for user/host/password

mysql select Host,Db,User,Table_Name,Table_priv from tables_priv;

will show similar information on a db/table basis for the host/user
combinations.
  Brad Eacker ([EMAIL PROTECTED])



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread Sami Maisniemi
On Monday 22 March 2004 22:43, [EMAIL PROTECTED] wrote:
 specify how to check the socket, please?

 Based on your ps information, the socket will likely be in the
 /usr/local/mysql/data/my.cnf file under the [mysqld] area.  Another way
 to tell if there is a socket open for the server would be to use

   netstat -a | grep 330

 Which would show a line similar to this:

 tcp0  0 *:3307  *:* LISTEN

It seems that the correct socket is used. Here is the output:

unix  2  [ ACC ] STREAM LISTENING 3303   private/relay
unix  2  [ ACC ] STREAM LISTENING 3307   public/showq
unix  3  [ ] STREAM CONNECTED 3330   
unix  3  [ ] STREAM CONNECTED 3309   
unix  3  [ ] STREAM CONNECTED 3306   
unix  3  [ ] STREAM CONNECTED 3305   
unix  3  [ ] STREAM CONNECTED 3302   
unix  3  [ ] STREAM CONNECTED 3301  

Regards Sami


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread beacker
 tcp0  0 *:3307  *:* LISTEN

It seems that the correct socket is used. Here is the output:

unix  2  [ ACC ] STREAM LISTENING 3303   private/relay
unix  2  [ ACC ] STREAM LISTENING 3307   public/showq

 Looks like 3307 is indeed open, so you may want to modify your
mysql_connect to use localhost:3307 - since that is likely to be the
port mysqld is using based upon this output.  The default is usually
3306, so if you do not include the :3307 port reference you may very
well not be able to connect.
Brad Eacker ([EMAIL PROTECTED])



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PHP script cannot connect MySQL server

2004-03-22 Thread beacker
Sami Maisniemi [EMAIL PROTECTED] writes:
 mysql use mysql
 mysql select User,Host,Password,Select_priv from user;

 which will show basic access capabilities for user/host/password

Hmmm ... did not work as you can see:

mysql select User,Host,Password,Select_priv from user;
ERROR 1054: Unknown column 'User' in 'field list'

 H, that's interesting.  You'll probably need to take a look
at the 'desc user;' output.  Mine reports the following initial
portion:

mysql desc user
- ;
+---+---+--+-+-
+---+
| Field | Type  | Null | Key | 
Default | Extra |
+---+---+--+-+-
+---+
| Host  | varchar(60) binary|  | PRI | 
|   |
| User  | varchar(16) binary|  | PRI | 
|   |
| Password  | varchar(16) binary|  | | 
|   |
| Select_priv   | enum('N','Y') |  | | N   
|   |

...

If yours does not report Host and User as the first two columns, your user
table has been corrupted in some manner.  You haven't tried to define your
own user table have you?  If so, that may be what is causing the errors.
  Brad Eacker ([EMAIL PROTECTED])



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]