debugsqlMinor
MySQL connection doesn't work anymore
Viewed 0 times
anymoremysqldoesnworkconnection
Problem
I had two MySQL servers running (127.0.0.1:3306 and 127.0.0.1:3307). Now I get this strange error:
What can I do now? How can I sanely restart the MySQL server?
Perhaps more importantly:
How can I make sure all the tables still exist?
mysql_connect(): Lost connection to MySQL server at 'reading initial communication packet' I can connect with localhost:3307, but there aren't any tables/databases. I'm fairly sure /etc/my.cnf is right:[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user = root
password = ***
[mysqld]
port = 3306
socket = /var/run/mysql/mysql.sock
[mysqld2]
port = 3307
socket = /var/run/mysql/mysql2.sockWhat can I do now? How can I sanely restart the MySQL server?
Perhaps more importantly:
How can I make sure all the tables still exist?
Solution
Here is one thing I quickly see is missing : Each [mysqld] needs to have its own datadir. No two mysqld groups can share the same datadir. You need to allocate different datadirs in different folders and make sure you run "chown -R mysql:mysql (datadir folder)" on all datadirs.
Your /etc/my.cnf should look something like this:
Check out this link from the Pythian Group on how to start and stop the individual DB services.
From my answer, you should see that there must be a complete copy of the data in /var/lib/mysql1, /var/lib/mysql2, etc.
Your /etc/my.cnf should look something like this:
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user = root
password = ***
[mysqld]
port = 3306
datadir = /var/lib/mysql1
socket = /var/run/mysql/mysql.sock
[mysqld2]
port = 3307
datadir = /var/lib/mysql2
socket = /var/run/mysql/mysql2.sockCheck out this link from the Pythian Group on how to start and stop the individual DB services.
From my answer, you should see that there must be a complete copy of the data in /var/lib/mysql1, /var/lib/mysql2, etc.
Code Snippets
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user = root
password = ***
[mysqld]
port = 3306
datadir = /var/lib/mysql1
socket = /var/run/mysql/mysql.sock
[mysqld2]
port = 3307
datadir = /var/lib/mysql2
socket = /var/run/mysql/mysql2.sockContext
StackExchange Database Administrators Q#3072, answer score: 4
Revisions (0)
No revisions yet.