Mary, you need to know 100% that mysql is actually running and what port or socket it is listening on for connections, before you even try and connect to it.
If you call mysqld directly with a script something like: #! /bin/sh # start-mysql-5.0.18 # # start the MySQL database server /usr/local/mysql-5.0.18/bin/mysqld \ --defaults-file=/usr/local/mysql-5.0.18/my.cnf \ --port=7000 \ --socket=/var/lib/mysql/mysql.sock \ --pid=/var/lib/mysql/laptop.pid \ --user=mysql \ --datadir=/var/lib/mysql & Then use a processes monitoring tool such as: http://www.student.nada.kth.se/~f91-men/qps/ This will then show you if mysqld is running OK. It will also show you the parameters in the above script that you passed to mysqld to get it started. You then need to try and connect to mysqld with the mysql monitor program as already mentioned. If you just set the client options in /etc/my.cnf config file, these will be applied globally to all mysql client programs. EG. # /etc/my.cnf # MySQL client program configuration file # last updated 2006-03-05 # mysqld server configuration file lives in # /usr/local/mysql-<version>/my.cnf #--------------------------------------------------------------------------- # mysql client program configuration options #--------------------------------------------------------------------------- [mysql] auto-rehash # needed for security - to stops multiple deletes/updates # without a where clause safe-updates #--------------------------------------------------------------------------- # The following options will be passed to all MySQL clients [client] socket = /var/lib/mysql/mysql.sock port = 7000 #snip #--------------------------------------------------------------------------- # end of mysql client program configurations # /etc/my.cnf More options for your mysqld server can be set in the --defaults-file=/usr/local/mysql-5.0.18/my.cnf These options are additional to the options you pass in the above script. EG #--------------------------------------------------------------------------- # mysqld server configuration options #--------------------------------------------------------------------------- [mysqld] basedir=/usr/local/mysql-5.0.18 ## use for testing multiple instances of mysqld ## these parameters are normally passed to mysqld ## from the start-mysql-5.0.18 script ## ##basedir=/usr/local/mysql-5.0.18 ##port=7005 ##socket=/usr/local/mysql-5.0.18/data/mysql.sock ##pid-file=/usr/local/mysql-5.0.18/data/laptop.pid ##datadir=/usr/local/mysql-5.0.18/data ##user=mysql server-id=1 #skip-networking skip-name-resolve skip-locking set-variable = key_buffer=16M set-variable = max_allowed_packet=1M set-variable = table_cache=64 set-variable = sort_buffer=512K set-variable = net_buffer_length=8K set-variable = myisam_sort_buffer_size=8M # logging options log=5-0-18.log log-bin=laptop-bin log-error=5-0-18.error-log log-queries-not-using-indexes log-slow-admin-statements log-slow-queries=5-0-18.slow-log log-warnings #--------------------------------------------------------------------------- # end of mysqld server configuration file # /usr/local/mysql-<version>/my.cnf Next you will need to check php is using the same socket to connect to mysqld server. Use the phpinfo() function in a php script, to verify this. Obviously, you will need the mysql or mysqli extension loaded for this. HTH Keith Roberts In theory, theory and practice are the same; In practice they are not. On Fri, 10 Mar 2006, Logan, David (SST - Adelaide) wrote: > To: Mary Adel <[EMAIL PROTECTED]> > From: "Logan, David (SST - Adelaide)" <[EMAIL PROTECTED]> > Subject: RE: php and mysql > > > If you still have issues after that, then read > http://dev.mysql.com/doc/refman/5.0/en/can-not-connect-to-server.html > > Regards > > > --------------------------------------------------------------- > ********** _/ ********** David Logan > ******* _/ ******* ITO Delivery Specialist - Database > ***** _/ ***** Hewlett-Packard Australia Ltd > **** _/_/_/ _/_/_/ **** E-Mail: [EMAIL PROTECTED] > **** _/ _/ _/ _/ **** Desk: +618 8408 4273 > **** _/ _/ _/_/_/ **** Mobile: 0417 268 665 > ***** _/ ****** > ****** _/ ******** Postal: 148 Frome Street, > ******** _/ ********** Adelaide SA 5001 > Australia > i n v e n t > --------------------------------------------------------------- > > -----Original Message----- > From: JC [mailto:[EMAIL PROTECTED] > Sent: Friday, 10 March 2006 6:42 AM > To: Mary Adel > Cc: [EMAIL PROTECTED]; mysql@lists.mysql.com > Subject: RE: php and mysql > > On Thu, 9 Mar 2006, Mary Adel wrote: > > > Thanks for al your help and i di that and now i have another error > > > > Can't connect to local MySQL server through socket > > '/var/lib/mysql/mysql.sock' (2) > > my code is as follows: > > > > <?php > > print "hi"; > > mysql_connect('localhost', 'root','') or die(mysql_error()); > > echo "Connected to MySQL<br />"; > > print "connected"; > > ?> > > if u can help in this i ll appreciate that a lot > > > > > > On Thu, 2006-03-09 at 13:37 -0500, fbsd_user wrote: > >> You need a login id and password unless this is test DB added under > >> ID "root" > >> You have to use the same login id as the one you created the > >> db/table with. > >> > >> mysql_connect('localhost', 'Login id', 'pw') or die(mysql_error()) > >> > >> mysql_connect('localhost', 'root') or die(mysql_error()) > >> > >> > >> -----Original Message----- > >> From: Mary Adel [mailto:[EMAIL PROTECTED] > >> Sent: Thursday, March 09, 2006 3:06 PM > >> To: mysql@lists.mysql.com > >> Subject: php and mysql > >> > >> > >> I have a severe problem that php5 cannot connect to mysql and i > >> don't > >> know why > >> also i am using linux > >> here is my peice of code > >> :<?php > >> print "hi"; > >> mysql_connect('localhost', '', '') or die(mysql_error()); > >> echo "Connected to MySQL<br />"; > >> print "connected"; > >> ?> > >> if their is any configuration please tell me > >> > >> thanks, > >> mary > >> > >> > >> -- > >> MySQL General Mailing List > >> For list archives: http://lists.mysql.com/mysql > >> To unsubscribe: > >> http://lists.mysql.com/[EMAIL PROTECTED] > >> > >> > > > > > > > > -- > > hi mary, > > take a look at > http://www.stanton-finley.net/fedora_core_5_installation_notes.html#MySQ > L. > > basically, you need to make sure that your mysql server accepts local > connection. > > if you login to your mysql server: > mysql -u root (if no password for root) or > mysql -u root -p (if there is pw for root) > > and then: > select user,host,password from mysql.user; > > if you don't see an entry for root & localhost, then you need to add it > in. > > hope that help. > JC > > -- > 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] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]