# apache with mysql and php support

## spyder

alright, if i install the packges for mysql, apache, and php support? 

what else do i have to do to get the interaction between them to work??

do i need to emerge any other packages?

----------

## Ethernal

I'm not sure, but I think you need mod_php and mod_sql as well, anyone who can confirm/deny this ?

----------

## Mat_le_ouf

To run pache with PHP4 support, just edit the /etc/conf.d/apache file and uncomment the following line :

```
APACHE_OPTS="-D PHP4"
```

And run apache with :

```
runscript /etc/init.d/apache start
```

I think that the link to be done with MySQL is between PHP and MySQL, apache has nothing to do in it...

Look in /etc/apache/conf/php.ini for PHP with MySQL.

----------

## spyder

root@spyder spyder # mysqladmin -u root password 'blargblarg'

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user: 'root@localhost' (Using password: NO)'

when i try to change the root password

----------

## Mat_le_ouf

Hmm, i'm not an expert in MySQL, I think someone else should be better to solve this problem...

However, is PHP working?

----------

## spyder

ya it is... :/

----------

## rac

 *spyder wrote:*   

> root@spyder spyder # mysqladmin -u root password 'blargblarg'
> 
> mysqladmin: connect to server at 'localhost' failed
> 
> error: 'Access denied for user: 'root@localhost' (Using password: NO)'
> ...

 

Probably a silly question, but is the server running?  "/etc/init.d/mysql start" if not.

----------

## fyerk

 *spyder wrote:*   

> root@spyder spyder # mysqladmin -u root password 'blargblarg'
> 
> mysqladmin: connect to server at 'localhost' failed
> 
> error: 'Access denied for user: 'root@localhost' (Using password: NO)'
> ...

 

Are you trying to change the root password or set the root password (for the first time) ?

----------

## rizzo

 *Ethernal wrote:*   

> I'm not sure, but I think you need mod_php and mod_sql as well, anyone who can confirm/deny this ?

 

You don't need mod_sql, but you want mod_php, not php.  Make sure you have "mysql" in your USE flags.  Then run these commands:

```
emerge apache mod_php mysql

/usr/bin/mysql_install_db

ebuild /var/db/pkg/dev-php/mod_php-4.2.2-r1/mod_php-4.2.2-r1.ebuild config

vi /etc/conf.d/apache (uncomment the line with "PHP4")

rc-update add apache default

rc-update add mysql default

/etc/init.d/mysql start

/etc/init.d/apache start

```

That should set you up.  I just did this morning.  I'm surprised there isn't a "Tips 'n Tricks" on this already.  If not I'll write one up.

----------

## darktux

The correct thing to do to connect to the MySQL daemon, would be 

```
mysql -uroot -p
```

 and then type in your password. If you have not yet set your password, then you should be able to log in just by typing mysql -urootLast edited by darktux on Sat Nov 16, 2002 10:47 pm; edited 1 time in total

----------

## slais-sysweb

 *spyder wrote:*   

> root@spyder spyder # mysqladmin -u root password 'blargblarg'
> 
> mysqladmin: connect to server at 'localhost' failed
> 
> error: 'Access denied for user: 'root@localhost' (Using password: NO)'
> ...

 

I had this problem yesterday it was cured by ensuring that /etc/hosts had an entry for the server that matched the name setup in /etc/hostname. 

```
127.0.0.1    localhost    yourserver.domain
```

may also work, but I seem to remember a note somewhere about this causing a problem with something so i suggest

 /etc/hostname

```
server.domain
```

and 

 /etc/hosts

```
127.0.0.1    localhost

xxx.x.x.x    server.domain    
```

----------

## spyder

thanks everyone..especially rizzo...i am trying that now..i'll let you know how it turns out..

----------

## spyder

root@spyder mp3sb_serv # mysql -u root -p < MySQL_create_Table.sql 

Enter password: 

ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

whats that mean??

----------

## lapu

 *spyder wrote:*   

> root@spyder mp3sb_serv # mysql -u root -p < MySQL_create_Table.sql 
> 
> Enter password: 
> 
> ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
> ...

 

Again a silly question, is server running

/etc/init.d/mysqld start

----------

## spyder

ya it has...

root@spyder spyder # /etc/init.d/mysql start

 * WARNING:  "mysql" has already been started.

root@spyder spyder # mysql

ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

----------

## lapu

 *spyder wrote:*   

> ya it has...
> 
> root@spyder spyder # /etc/init.d/mysql start
> 
>  * WARNING:  "mysql" has already been started.
> ...

 

Do you have /var/run/mysqld/mysqld.sock

----------

## spyder

ya it's there

spyder@spyder spyder $ ls -la /var/run/mysqld/

total 8

drwxr-xr-x    2 mysql    mysql        4096 Nov 17 03:01 .

drwxr-xr-x    4 root     root         4096 Nov 17 03:07 ..

srwxrwxrwx    1 mysql    mysql           0 Nov 17 03:01 mysqld.sock

----------

## oblique effect

First off, I noticed that you haven't tried doing just 'mysql -u root'. I know that the first time you startup mysql and login to it there is no root password set. maybe try issueing 'mysqladmin -u root -password 'newpasswd'. There is more help and better answers in other places, like www.linuxnewbie.org

Hope that leads you the right direction.

oblique

----------

## spyder

spyder@spyder spyder $ mysql -u root

ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

----------

## rac

Do you have Unix domain socket support in your kernel?

----------

## spyder

ya i do

----------

## spyder

please help me figure this out

----------

## lapu

Have you installed strace.

What says #strace mysql

.....

connect(3, {sin_family=AF_UNIX, path="/var/run/mysqld/mysqld.sock"}, 110) = -1 ENOENT (No such file or directory)

.....

or

....

connect(3, {sin_family=AF_UNIX, path="/var/run/mysqld/mysqld.sock"}, 110) = 0

...

----------

## spyder

connect(3, {sin_family=AF_UNIX, path="/tmp/mysqld.sock"}, 110) = -1 ECONNREFUSED (Connection refused)

----------

## spyder

i tried changing it back to the original place andi got this

connect(3, {sin_family=AF_UNIX, path="/var/run/mysqld/mysqld.sock"}, 110) = -1 ENOENT (No such file or directory)

----------

## lapu

is apache using  /tmp/mysqld.sock

and mysql uses /var/run/mysqld/mysqld.sock?

check out  /etc/mysql/my.conf

and  /etc/apache/conf/php.ini

----------

## spyder

apache has nothing to do with it yet...just from teh console of linux i can't run mysql

----------

## pato

This might be something completely off the wall, but you are root while you are trying all this, right? Just asking, because I know from experience that /var/lib/mysql is usually not world-readable, therefore users other than root can't get access to the socket. I usually change /etc/my.cnf to put the socket file in /tmp. Normally, you don't see the socket access error when you are running as root. It's not until you get everything set up that you realize ordinary users can't get access to the socket in /var/lib/mysql. 

If this is the first time you are trying to log into mysql after installation, you should be able to just type 'mysql' as root and get a mysql> prompt right away, since there isn't a password for root by default. 

HTH

----------

## spyder

i was su'd to root

----------

## spyder

i just tried it logged in as root, not su'ing to root

still the same thing...

----------

## mooman

Most of the google Groups stuff I turned up on this had to do with either chroot being the problem/fix or a config file setting:

link

and suggest doing a test to see if the mysql listener is running:

netstat -an|grep mysql

Anyway, I'm not at the mysql step on my box yet.. still beating on apache itself  or I might be more help..  :Smile: 

EDIT (rac): inlined link to avoid phpBB line break uglyness.

----------

## spyder

root@spyder spyder # netstat -an|grep mysql 

root@spyder spyder # 

nothing...

root@spyder spyder # ls -la /tmp/mysqld.sock 

srwxrwxrwx    1 mysql    mysql           0 Nov 18 17:29 /tmp/mysqld.sock

root@spyder spyder # 

is a byte size of 0 correct??? thats what it made when i first ran safe_mysqld

----------

## spyder

root@spyder spyder # mysqladmin -h localhost version

mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (111)'

Check that mysqld is running and that the socket: '/tmp/mysqld.sock' exists!

----------

## mooman

Okay, so netstat shows that it's not listening.

How about seeing if the mysqld process is even running...?

ps -A | grep mysqld

Mysqladmin can't possibly work if Mysql itself isn't running, so that's probably where the attention should be focused.

----------

## mooman

Here's a thread I ran across about starting mysql as a user:

The last post has some info about starting up mysql.. maybe something there is useful?

EDIT (rac): inlined link to avoid phpBB linebreak uglyness.

----------

## ozukir@

I had a similar problem, same messages at least. Try:

```
$mysql -u root -h YOURHOSTNAME.DOMAIN -p
```

That's what I had to do to initially log on. Then I grant priviledges to root@localhost. Hope that helps.

----------

## lapu

/etc/mysql/my.conf

...

[client]

#password	= my_password

port		= 3306

socket		= /var/run/mysqld/mysqld.sock

#socket           =/tmp/mysqld.sock

[safe_mysqld]

err-log		= /var/log/mysql/mysql.err

[mysqld]

#skip-networking

skip-innodb

user		= mysql

pid-file	= /var/run/mysqld/mysqld.pid

socket		= /var/run/mysqld/mysqld.sock

#socket          =/tmp/mysqld.sock

port		= 3306

log		= /var/log/mysql/mysql.log

basedir		= /usr

datadir		= /var/lib/mysql

tmpdir		= /tmp

language	= /usr/share/mysql/english

skip-locking

...

#/etc/init.d/mysql start

# ls -la /var/run/mysqld/mysqld.sock

srwxrwxrwx    1 mysql    mysql           0 Nov  8 04:47 /var/run/mysqld/mysqld.sock

# mysqladmin --socket=/var/run/mysqld/mysqld.sock version

mysqladmin  Ver 8.23 Distrib 3.23.52, for pc-linux-gnu on i686

Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL license

Server version          3.23.52-log

Protocol version        10

Connection              Localhost via UNIX socket

UNIX socket             /var/run/mysqld/mysqld.sock

Uptime:                 5 min 14 sec

Threads: 2  Questions: 2  Slow queries: 0  Opens: 6  Flush tables: 1  Open tables: 0 Queries per second avg: 0.006

#strace mysql

....

connect(3, {sin_family=AF_UNIX, path="/var/run/mysqld/mysqld.sock"}, 110) = 0

....

hope this will help

----------

## spyder

that didn't work either

----------

