LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-30-2004, 10:25 PM   #1
MikeFoo1
Member
 
Registered: Apr 2004
Distribution: Slackware 9.1
Posts: 72

Rep: Reputation: 15
php / mysql connection problem .


Hi ,

i get this error :



Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
.
PHP Code:
$con=mysql_connect() or die("Problem".mysql_error());
print 
"Successfully connected.\n";

mysql_close($con); 

The weird thing is that i can connect to mysql in my java programs etc.



Quote:
mysqladmin status
Uptime: 1791 Threads: 1 Questions: 5 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 0 Queries per second avg: 0.003

also,
Quote:
mysqladmin ping
mysqld is alive
So, i am guessing i have to edit something to get it working.

ps i am running Slackware 9.0 , default mysql installation.

the phpinfo(); gives this:

Quote:
Active Persistent Links 0
Active Links 0
Client API version 3.23.49
MYSQL_MODULE_TYPE builtin
MYSQL_SOCKET /tmp/mysql.sock <----
MYSQL_INCLUDE no value
MYSQL_LIBS no value
i have edited the php.ini and i have the following:

Quote:
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1

; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = -1

; 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 =/var/run/mysql/mysql.sock

; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =

; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =
Do i have to edit anyting else ?

Any help would be appreciated.
 
Old 05-01-2004, 05:10 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It may be a stupid question, but...do you run mysql_connect() without or with parameters? If you don't give any parameters, do the defaults fit?

From php.net:
Quote:
The following defaults are assumed for missing optional parameters: server = 'localhost:3306', username = name of the user that owns the server process and password = empty password.
 
Old 05-01-2004, 06:33 PM   #3
MikeFoo1
Member
 
Registered: Apr 2004
Distribution: Slackware 9.1
Posts: 72

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Mara
It may be a stupid question, but...do you run mysql_connect() without or with parameters? If you don't give any parameters, do the defaults fit?

From php.net:
Yes, i do have host,usrer,password fields defined.Still, can't connect.

If i edit the php.ini file , it is supposed to change when i call phpinfo(); right ?

Currently i have :


Quote:
Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value

mysql.default_socket no value no value <-but i already changed it to /var/run/mysql/mysql.sock

mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
Could someone post their php.ini here ?


Thanks.
 
Old 05-02-2004, 05:22 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
In my case (php.ini file) :
Code:
[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
(and it works)
So it looks it's rather not a php.ini problem in your case.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php-mysql connection pb abd_bela Debian 2 09-23-2005 04:07 AM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
Remote Mysql Connection in PHP ElementNine Programming 2 05-03-2004 04:24 PM
PHP > MySQL connection password security question Wibble Linux - Security 4 04-22-2004 03:19 PM
problem with mysql and php nshoboul Linux - Software 3 11-07-2003 02:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration