# MySQL remote access

## sjames1010

This question has been asked multiple times, but none of the answers have worked for me. The MySQL ebuild really needs to be better at easy configuration. There should be a HowTo on this. If I ever get it working maybe I'll write one.

list of dups (please don't mark this as one, these did not help me)

https://forums.gentoo.org/viewtopic.php?t=162233

https://forums.gentoo.org/viewtopic.php?t=149985

https://forums.gentoo.org/viewtopic.php?t=118648

https://forums.gentoo.org/viewtopic.php?t=38377

https://forums.gentoo.org/viewtopic.php?t=26815

I can login to mysql with:

```
mysql -u root -p
```

but not with:

```
mysql -h phoenix2 -u root -p

Enter password:

ERROR 2013: Lost connection to MySQL server during query

```

(phoenix2 is the machine's hostname)

In other words, I cannot log in except from the localhost.

my.cnf includes the lines:

```

bind-address    = 0.0.0.0

port            = 3306

# this can make it even more secure:

#skip-networking

```

hosts.allow is:

```
mysqld: ALL
```

hosts.deny is empty

netstat shows:

```
netstat -lntp

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:3306            0.0.0.0:*               LISTEN      22709/

tcp        0      0 0.0.0.0:6667            0.0.0.0:*               LISTEN      22272/bitlbeed

tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      22584/

tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      22534/perl

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      22229/apache2

tcp        0      0 0.0.0.0:723             0.0.0.0:*               LISTEN      -

tcp        0      0 0.0.0.0:8021            0.0.0.0:*               LISTEN      22584/

tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      22486/vsftpd

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      22442/sshd

```

----------

## rmalolepszy

Is your user allowed to log in from non-localhost in your user table?

----------

## sjames1010

I think this is set up correctly. I used the webmin mysql module.

```
mysql -u root -p mysql

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1 to server version: 4.0.20

                                                                                                                                

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

                                                                                                                                

mysql> select user,host,password from user;

+-------+-----------+------------------+

| user  | host      | password         |

+-------+-----------+------------------+

| root  | localhost | **************** |

| root  | phoenix2  | **************** |

...

```

----------

## rmalolepszy

phoenix2 is the host your connecting from?

----------

## banadushi

More than likely 'phoenix2' is not resolveable by the machine, is it in your /etc/hosts can you ping 'phoenix2' from your MySQL server's console?

For speed and effeciency you should be using IP's for host grants, not hostnames, then turning off name resolution.  This will speed up MySQL alot, if you have a very busy database server.

Happy Hacking!

----------

## sjames1010

Yes phoenix2 is the host I'm connecting from.

/etc/hosts does have phoenix2 in it, but it has sounded like a name resolution problem to me, too. I added "skip-name-resolve" to /etc/mysql/my.cnf. Is this the proper way to disable name resolution?

```
mysql -u root -h 64.205.232.136

ERROR 2013: Lost connection to MySQL server during query

```

(I removed the passwords)

This is getting rather frustrating. I noticed that the init script starts mysql from "/usr/bin/mysqld_safe" ... Is this a problem? It seems like just a script to keep mysql alive when it dies.

----------

## Herring42

Stupidly, I made two changes at once, so I don't know which one cured the problem, but I upgraded to the latest ~x86 version of MySql, and at the same time compiled without tcp wrappers support.

```

ACCEPT_KEYWORDS="~x86" USE="-tcpd" emerge -v mysql

```

This has upgraded me to version 4.0.20.

Hope this helps you too.

----------

