# MySQL connection troubles

## jemdogs

I'm having some problems connecting to MySQL. They started before I was even done with the install. I ran mysql_install_db and it told me to set the root password using the commands below.

```

/etc/init.d/mysql start (you have to start the server first!)

/usr/bin/mysqladmin -u root -h blackbox password 'new-password'

/usr/bin/mysqladmin -u root password 'new-password'

```

When I tried the first one, it told me MySQL was already started. No big deal I guess. Then the next two commands produced the following two errors, respectively:

```

/usr/bin/mysqladmin: connect to server at 'blackbox' failed

error: 'Lost connection to MySQL server during query'

```

```

/usr/bin/mysqladmin: connect to server at 'localhost' failed

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

```

I tried adding "mysqld: ALL" to /etc/hosts.allow, that did nothing. I was able to access the MySQL module in Webmin however, so I thought I was good to go. But when I tried to install phpMyAdmin, I got a similar error:

#2013 - Lost connection to MySQL server during query

Does anyone know what could be causing this problem?

P.S. Also, I cannot access anything hosted by my Apache2 server from the server itself. The browser tells me that that port is blocked for security reasons. However it works fine on the workstation right next to it. Any ideas??

Thanks  :Smile: 

----------

## adaptr

You seem to be having some iptables problems, then  :Wink: 

----------

## jemdogs

I dont have iptables emerged... or... is that the problem?   :Wink: 

----------

## adaptr

Maybe not, then.

But why do you say that:

 *Quote:*   

> I cannot access anything hosted by my Apache2 server from the server itself. The browser tells me that that port is blocked for security reasons

 

What do you mean by this ?

Could you post output of

```
netstat -ltpn
```

----------

## jemdogs

I mean that when I open any browser (Galeon, Firebird, etc.) on the box running Apache, I get a popup message from the browser telling me that that port (Apache is running on 17 as of this post, I've tried changing it to try to resolve this problem but it didnt work) is blocked for "security reasons".

netstat -ltpn output:

```
Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State

PID/Program name

tcp        0      0 0.0.0.0:5984            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5952            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5953            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5954            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5960            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5961            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5962            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN

1135/mysqld

tcp        0      0 0.0.0.0:5963            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN

1379/smbd

tcp        0      0 0.0.0.0:5964            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN

1781/XDirectFB

tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN

1459/perl

tcp        0      0 0.0.0.0:17              0.0.0.0:*               LISTEN

1155/apache2

tcp        0      0 0.0.0.0:5970            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5971            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5972            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5973            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 192.168.1.17:21         0.0.0.0:*               LISTEN

1330/pure-ftpd (SER

tcp        0      0 0.0.0.0:5974            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN

1136/sshd

tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN

1155/apache2

tcp        0      0 0.0.0.0:5980            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5981            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5982            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5950            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5983            0.0.0.0:*               LISTEN

1726/xinetd

tcp        0      0 0.0.0.0:5951            0.0.0.0:*               LISTEN

1726/xinetd

```

----------

## adaptr

Apache on port 17 ?

Why ?

Please run well-known services on well-known port sunless you have a very (very) good reason not to...

And what are all those high ports on the server ?

I can see that they're all controlled by xinetd, so what services ?

----------

## jemdogs

I run Apache on port 17 because my ISP blocks port 80 on all clients to prevent people from hosting and 17 was easy for me to remember.   :Smile: 

As for the high port numbers and all the xinetd services, I have no idea what they are.   :Confused:  I certainly didnt create them knowingly. My guess is that they are something that has been instanciated several times without being terminated. Oddly, the computer had only been up for about 30mins as of the post I made above containing the netstat output, so there wasnt a significant amount of user interaction with the system that would explain so many instances of xinetd.

----------

## adaptr

Look in /etc/xinetd.d/ and read /etc/inetd.conf to see what service(s) these are.

There's nothing mysterious on a Linux system...

About the blocked apache port - if you're sure you're not running iptables, and have allowed access from 127.0.0.1 in apache.conf - I've run out of clues.

----------

## bUg-

You better check your /etc/hosts.deny and /etc/hosts.allow, making sure you have a line similar to the following in /etc/hosts.allow: 

mysqld: ALL (this will give permissions for ALL hosts to make a tcp connection to your mysqld service)

----------

## stickboy2642

Here are a couple things to check when logging into the mysql server.  First off, I see that you are trying to connect using "root" but with no password.  Use the -p flag and when it prompts for a password, just hit enter.  That should let you log in as root before you reset the password.

Second issue, check your /etc/my.cnf file and comment out the line that says 'bind-address=127.0.0.1' (or something to that effect).  This is set by default and essentially turns off networking for the database.  If that line is in the config file, you will not be able to log in from any other machine. I have been burned by this one a couple of times before.

Hope this helps!

Steve

----------

