dbTalk Databases Forums  

mysql - can't connect through apache

comp.databases.mysql comp.databases.mysql


Discuss mysql - can't connect through apache in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
The Natural Philosopher
 
Posts: n/a

Default Re: mysql - can't connect through apache - 01-18-2012 , 06:21 PM






cerr wrote:
Quote:
On Jan 18, 12:42 pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid
wrote:
cerr wrote:
On Jan 17, 12:24 pm, cerr <ron.egg... (AT) gmail (DOT) com> wrote:
On Jan 17, 12:09 pm, Luuk <L... (AT) invalid (DOT) lan> wrote:
On 17-01-2012 18:56, cerr wrote:
Hi,
I have a LAMP installation. I can properly access my db from the shell
but am not able to get in via apache, with phpmyadmin or Joomla e.g.
Any clues?
I'm pretty muich stuck, I tried configuring stuff around,
root@localhost with password works just fine on the shell.... but i'm
notable to use that user to login with either, phpmyadmin nor joomla.
Any hints?
Heklp would be appreciated!
Thanks alot!
Ron
What is the output of:
netstat -antp | grep 3306
It should show something like:
tcp 0 0 0.0.0.0:3306 0.0.0.0:*
LISTEN -
Yep, I got
root@reg-desktop:~# netstat -antp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:*
LISTEN 13136/mysqld
which means MySQL is listening on port 3306 to receive requests.
After that, write a PHP-page (i.e. phpinfo.php)like this:
?php
phpinfo();
?
It should give you all kinds of info about your system.
There is some info about how ( and if) PHP can contact MySQL
for an example of the output you should get:http://example.com.customers.tigertech.net/phpinfo.php
(scroll down to see the 'mysql' info....)
My output looks a little different:
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
Directive Local Value Master Value
mysql.allow_local_infile On On
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 /opt/lampp/var/mysql/mysql.sock /opt/lampp/var/
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
No one here that can help me?
I would GUESS that your default installation wont connecte except by
either the unix socket /opt/lampp/var/mysql/mysql.sock

or on the loopback interface 127.0.0.1

I found when setting up my own system that the c library API didnt like
'localhost' but was happy with '127.0.0.1'

I'll see what my.conf says ...

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently
parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

Yep, I have tried with 127.0.0.1 and localhost and then read that when
it's commented out, it'll just take your current IP. And taht's what I
ended up doing, but just to try again, I set it back to 127.0.0.1 now,
triggered a "/etc/init.d/mysql restart" but still no change...
Now that will accept connections on both the .sock unix socket and
127.0.0.1:3306

It may be that one or other of the programs is expecting that to be
active, and it isn't

edit the file /etc/mysql/my.cnf and restart mysqld..

That's a bummer! I can't believe it!!!! Why is this? How what else
could be messed up, maybe my MySQLi installation...? How could I get
this fixed...?

You HAVE got the mysql extensions to php installed?
what does phpinfo have to say..

Reply With Quote
  #12  
Old   
cerr
 
Posts: n/a

Default Re: mysql - can't connect through apache - 01-18-2012 , 06:22 PM






On Jan 18, 4:21*pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid>
wrote:
Quote:
cerr wrote:
On Jan 18, 12:42 pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid
wrote:
cerr wrote:
On Jan 17, 12:24 pm, cerr <ron.egg... (AT) gmail (DOT) com> wrote:
On Jan 17, 12:09 pm, Luuk <L... (AT) invalid (DOT) lan> wrote:
On 17-01-2012 18:56, cerr wrote:
Hi,
I have a LAMP installation. I can properly access my db from the shell
but am not able to get in via apache, with phpmyadmin or Joomla e.g.
Any clues?
I'm pretty muich stuck, I tried configuring stuff around,
root@localhost with password works just fine on the shell.... but i'm
notable to use that user to login with either, phpmyadmin nor joomla.
Any hints?
Heklp would be appreciated!
Thanks alot!
Ron
What is the output of:
netstat -antp | grep 3306
It should show something like:
tcp * * * *0 * * *0 0.0.0.0:3306 * * * * * *0.0.0.0:*
LISTEN * * *-
Yep, I got
root@reg-desktop:~# netstat -antp | grep 3306
tcp * * * *0 * * *0 0.0.0.0:3306 * * * * * *0.0.0.0:*
LISTEN * * *13136/mysqld
which means MySQL is listening on port 3306 to receive requests.
After that, write a PHP-page (i.e. phpinfo.php)like this:
?php
* phpinfo();
?
It should give you all kinds of info about your system.
There is some info about how ( and if) PHP can contact MySQL
for an example of the output you should get:http://example.com.customers.tigertech.net/phpinfo.php
(scroll down to see the 'mysql' info....)
My output looks a little different:
MySQL Support * *enabled
Active Persistent Links *0
Active Links * * 0
Client API version * * * mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
Directive * * * *Local Value * * Master Value
mysql.allow_local_infile * * * * On * * *On
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 * * /opt/lampp/var/mysql/mysql.sock * ** * /opt/lampp/var/
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
No one here that can help me?
I would GUESS that your default installation wont connecte except by
either the unix socket /opt/lampp/var/mysql/mysql.sock

or on the loopback interface 127.0.0.1

I found when setting up my own system that the c library API didnt like
'localhost' but was happy with '127.0.0.1'

I'll see what my.conf says ...

[client]
port * * * * * *= 3306
socket * * * * *= /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently
parsed.
[mysqld_safe]
socket * * * * *= /var/run/mysqld/mysqld.sock
nice * * * * * *= 0

[mysqld]
#
# * Basic Settings
#
user * * * * * *= mysql
pid-file * * * *= /var/run/mysqld/mysqld.pid
socket * * * * *= /var/run/mysqld/mysqld.sock
port * * * * * *= 3306
basedir * * * * = /usr
datadir * * * * = /var/lib/mysql
tmpdir * * * * *= /tmp
language * * * *= /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address * * * * * *= 127.0.0.1

Yep, I have tried with 127.0.0.1 and localhost and then read that when
it's commented out, it'll just take your current IP. And taht's what I
ended up doing, but just to try again, I set it back to 127.0.0.1 now,
triggered a "/etc/init.d/mysql restart" but still no change...
Now that will accept connections on both the .sock unix socket and
127.0.0.1:3306

It may be that one or other of the programs is expecting that to be
active, and it isn't

edit the file /etc/mysql/my.cnf and restart mysqld..

That's a bummer! I can't believe it!!!! Why is this? How what else
could be messed up, maybe my MySQLi installation...? How could I get
this fixed...?

You HAVE got the mysql extensions to php installed?
what does phpinfo have to say..
see http://24.82.166.99/phpinfo.php

Reply With Quote
  #13  
Old   
The Natural Philosopher
 
Posts: n/a

Default Re: mysql - can't connect through apache - 01-18-2012 , 06:33 PM



The Natural Philosopher wrote:
Quote:
cerr wrote:
On Jan 18, 12:42 pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid
wrote:
cerr wrote:
On Jan 17, 12:24 pm, cerr <ron.egg... (AT) gmail (DOT) com> wrote:
On Jan 17, 12:09 pm, Luuk <L... (AT) invalid (DOT) lan> wrote:
On 17-01-2012 18:56, cerr wrote:
Hi,
I have a LAMP installation. I can properly access my db from the
shell
but am not able to get in via apache, with phpmyadmin or Joomla e.g.
Any clues?
I'm pretty muich stuck, I tried configuring stuff around,
root@localhost with password works just fine on the shell.... but
i'm
notable to use that user to login with either, phpmyadmin nor
joomla.
Any hints?
Heklp would be appreciated!
Thanks alot!
Ron
What is the output of:
netstat -antp | grep 3306
It should show something like:
tcp 0 0 0.0.0.0:3306 0.0.0.0:*
LISTEN -
Yep, I got
root@reg-desktop:~# netstat -antp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:*
LISTEN 13136/mysqld
which means MySQL is listening on port 3306 to receive requests.
After that, write a PHP-page (i.e. phpinfo.php)like this:
?php
phpinfo();
?
It should give you all kinds of info about your system.
There is some info about how ( and if) PHP can contact MySQL
for an example of the output you should
get:http://example.com.customers.tigertech.net/phpinfo.php
(scroll down to see the 'mysql' info....)
My output looks a little different:
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version mysqlnd 5.0.8-dev - 20102224 - $Revision:
310735 $
Directive Local Value Master Value
mysql.allow_local_infile On On
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 /opt/lampp/var/mysql/mysql.sock
/opt/lampp/var/
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
No one here that can help me?
I would GUESS that your default installation wont connecte except by
either the unix socket /opt/lampp/var/mysql/mysql.sock

or on the loopback interface 127.0.0.1

I found when setting up my own system that the c library API didnt like
'localhost' but was happy with '127.0.0.1'

I'll see what my.conf says ...

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently
parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

Yep, I have tried with 127.0.0.1 and localhost and then read that when
it's commented out, it'll just take your current IP. And taht's what I
ended up doing, but just to try again, I set it back to 127.0.0.1 now,
triggered a "/etc/init.d/mysql restart" but still no change...
Now that will accept connections on both the .sock unix socket and
127.0.0.1:3306

It may be that one or other of the programs is expecting that to be
active, and it isn't

edit the file /etc/mysql/my.cnf and restart mysqld..

That's a bummer! I can't believe it!!!! Why is this? How what else
could be messed up, maybe my MySQLi installation...? How could I get
this fixed...?

You HAVE got the mysql extensions to php installed?
what does phpinfo have to say..
hang on...it looks like php is looking for it in a different place..

its at /var/run/mysqld/mysqld.sock

but the phpinfo says its looking in:

/opt/lampp/var/mysql/mysql.sock

check this section

; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php.net/mysql.default-socket
mysql.default_socket =

in the file /etc/php5/apache2/php.ini file

That's the file apache uses to fire up php with..

Reply With Quote
  #14  
Old   
Peter H. Coffin
 
Posts: n/a

Default Re: mysql - can't connect through apache - 01-18-2012 , 07:22 PM



On Wed, 18 Jan 2012 13:34:57 -0800 (PST), cerr wrote:
Quote:
On Jan 18, 12:42?pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid
wrote:
cerr wrote:
On Jan 17, 12:24 pm, cerr <ron.egg... (AT) gmail (DOT) com> wrote:
On Jan 17, 12:09 pm, Luuk <L... (AT) invalid (DOT) lan> wrote:

On 17-01-2012 18:56, cerr wrote:
Hi,
I have a LAMP installation. I can properly access my db from the shell
but am not able to get in via apache, with phpmyadmin or Joomla e.g.
Any clues?
I'm pretty muich stuck, I tried configuring stuff around,
root@localhost with password works just fine on the shell.... but i'm
notable to use that user to login with either, phpmyadmin nor joomla.
Any hints?
Heklp would be appreciated!
Thanks alot!
Ron
What is the output of:
netstat -antp | grep 3306
It should show something like:
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:3306 ? ? ? ? ? ?0.0.0.0:*
LISTEN ? ? ?-
Yep, I got

root@reg-desktop:~# netstat -antp | grep 3306
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:3306 ? ? ? ? ? ?0.0.0.0:*
LISTEN ? ? ?13136/mysqld

which means MySQL is listening on port 3306 to receive requests.
After that, write a PHP-page (i.e. phpinfo.php)like this:
?php
? phpinfo();
?
It should give you all kinds of info about your system.
There is some info about how ( and if) PHP can contact MySQL
for an example of the output you should get:http://example.com.customers.tigertech.net/phpinfo.php
(scroll down to see the 'mysql' info....)
My output looks a little different:
MySQL Support ? ?enabled
Active Persistent Links ?0
Active Links ? ? 0
Client API version ? ? ? mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $

Directive ? ? ? ?Local Value ? ? Master Value
mysql.allow_local_infile ? ? ? ? On ? ? ?On
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 ? ? /opt/lampp/var/mysql/mysql.sock ? ? ? ? /opt/lampp/var/
mysql/mysql.sock
mysql.default_user ? ? ?no value ? ? ? ?no value
mysql.max_links ?Unlimited ? ? ? Unlimited
Several things all need to be correct.

mysqld has to establish the socket in the same place that php is looking
for it.

You have to use a user ID that's authorized to connect using that method
that is being attempted.

Maybe you gave the exact error message, but I don't remember it offhand.
The key is in that error message.

We know php is looking for the socket at /opt/lampp/var/mysql/mysql.sock
We don't know where mysqld put it. use the shell mysql command to make
sure that's the same:

mysql> show variables where variable_name = 'socket';

Also make sure that the combination of user ID and connection method
exists.

mysql> select user, host from mysql.user;
+-----------+-------------------------+
Quote:
user | host |
+-----------+-------------------------+
root | 127.0.0.1 |
root | localhost |
root | nibelheim.ninehells.com |
+-----------+-------------------------+
3 rows in set (0.00 sec)

Your results will be different. If it says "localhost" then that ID can
use the unix socket. If you've chrooted your apache, then that socket
may not be where you think it is. Maybe you'll have to tell php that
it's in /var/mysql/mysql.sock instead of /opt/lampp/var/mysql/mysql.sock
if it's been chrooted into /opt/lampp or something. If it says
127.0.0.1, then you can connect via loopback TCP. THIS IS ***NOT***
"localhost". 127.0.0.1 can be reached by specifying 127.0.0.1 as the
server, or "Localhost" or "lOcAlHoSt" but not "localhost" -- "localhost"
means the OS socket. (This oddball thing is the thing that old hands
forget is stupid and forget to ask about and underscore, and even after
dozens of rewrites of the doco, the documentation still forgets to
mention more than like half the time.) If you've got a hostname option
there or '%', then you can connect from the specified hostname or any
other network host that matches the wildcard. Just remember also that
127.0.0.1 only accepts connections from other loopback addresses, and
those don't usually have domain extensions. Which can complicate things
if you have (for example) only host entries for 'localhost' and
'%.example.invalid' or whatever upper-level domain mask, 'cause (I
think) that means you cannot connect via loopback tcp, and "Localhost"
won't work.

--
93. If I decide to hold a double execution of the hero and an underling
who failed or betrayed me, I will see to it that the hero is
scheduled to go first.
--Peter Anspach's list of things to do as an Evil Overlord

Reply With Quote
  #15  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: mysql - can't connect through apache - 01-19-2012 , 03:23 AM



Luuk <Luuk (AT) invalid (DOT) lan> wrote:
Quote:
On 18-01-2012 21:42, The Natural Philosopher wrote:

I found when setting up my own system that the c library API didnt like
'localhost' but was happy with '127.0.0.1'

because 'netstat -ant.....' said:
0.0.0.0:3306

mysql MUST be listening to more that just 'localhost', or '127.0.0.1'

If it's just listenting to 'localhost' it would have said:
127.0.0.1:3306
Guys, please stop it! You sound like blind discussion colors.

'localhost' and '127.0.0.1' are completely different things for the
MySQL server. This is by design and well documented:

http://dev.mysql.com/doc/refman/5.1/en/connecting.html


@ron

I guess you have Apache + MySQL running on the same machine? Then you
should connect to MySQL via 'localhost' and configure MySQL to not
listen on any outbound network (skip-networking). However then MySQL
and PHP must agree upon the location of the MySQL socket. So check your
php.ini and modify/add the line where the MySQL socket is defined, to
point to the same location that is used in my.cnf.

It's very likely that ATM PHP tries to connect MySQL on a nonexisting
socket. The Apache error log will have the details.


XL

Reply With Quote
  #16  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: mysql - can't connect through apache - 01-19-2012 , 03:27 AM



cerr <ron.eggler (AT) gmail (DOT) com> wrote:

Quote:
what does phpinfo have to say..

see http://24.82.166.99/phpinfo.php
Oh. Look:

mysql.default_socket /opt/lampp/var/mysql/mysql.sock /opt/lampp/var/mysql/mysql.sock

This is very probably *not* the same as MySQL is using.


XL

Reply With Quote
  #17  
Old   
Luuk
 
Posts: n/a

Default Re: mysql - can't connect through apache - 01-19-2012 , 01:09 PM



On 19-01-2012 10:23, Axel Schwenke wrote:
Quote:
Luuk <Luuk (AT) invalid (DOT) lan> wrote:
On 18-01-2012 21:42, The Natural Philosopher wrote:

I found when setting up my own system that the c library API didnt like
'localhost' but was happy with '127.0.0.1'

because 'netstat -ant.....' said:
0.0.0.0:3306

mysql MUST be listening to more that just 'localhost', or '127.0.0.1'

If it's just listenting to 'localhost' it would have said:
127.0.0.1:3306

Guys, please stop it! You sound like blind discussion colors.

'localhost' and '127.0.0.1' are completely different things for the
ah, a reference to the 'worst' part of yhe MySQL documentation

it says:
"The default host name is localhost. On Unix, this has a special
meaning, as described later. "

but it should say:
"The default host name is localhost. With MySQL, this has a special
meaning, as described later. "


Quote:
MySQL server. This is by design and well documented:

http://dev.mysql.com/doc/refman/5.1/en/connecting.html

'
--
Luuk

Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.