Re: Lost connection to MySQL server at 'reading initial communication packet', system error: 111
Robert Moore Wrote:
-------------------------------------------------------
> I grappled with this issue for several hours
> yesterday and I eventually got it working by
> matching the "remote address" in the SSH command
> to the bind-address value in the my.cnf file on
> the remote server. ...
I briefly had a problem with system error:111, but
I'm quite sure it was of my own making.
-- Fedora 9 on a remote server
-- PuTTY/SSH from a Windows machine
I got off on the wrong foot somehow in the installation
(yum install mysql mysql-server). Over the course of the
last 30 hours or so, I got a lot of error messages:
"mysqladmin: connect to server at 'localhost' failed"
"ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)"
"'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'"
"BHost 'localhost' is not allowed to connect to this MySQL serverConnection"
I think I caused a lot of problems for myself trying to figure out how get
logged in for the first time and set the root password.
I've probably visited a couple of hundred web pages and tried
a lot of things. For me, the "Lost connection" error was probably
related to getting my setup confused between two different sockets:
/var/lib/mysql/mysql.sock
/var/run/mysqld/mysqld.sock
I also relentlessly reset permissions for all of the mysql folders.
Uninstalled, deleted mysql data directory, reinstalled. I've lost
count of how many times.
This line is what got me on the right path:
/usr/bin/mysqld_safe --user=mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --datadir=/var/lib/mysql --skip-grant-tables --skip-networking &
Before I came across that, every time I could not connect
to the server.
This is /etc/my.conf now:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port=3306
tmpdir = /tmp
user=root
skip-networking
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/var/lib/mysql/mysql.sock
And, following another tip, I put a link in /tmp
in case my client looks for the sock in /tmp:
mysql.sock -> /var/lib/mysql/mysql.sock
The last little piece that fell into place
was that at some point--who knows when?--I
had tried user=mysql in my.cnf. When I
noticed that and set it to user=root,
I was finally able to get into mysql, set
my password, create a user, get rid of the
anonymous user(s), and drop test.
At any rate, I want to thank you for your post.
It was very interesting even though I'm not trying
to do anything so slick and sophisticated.
Thanks!