Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-29-2008, 08:27 PM
Nanni Claudio
 
Posts: n/a
Default R: Starting a 2nd MySQL instance on UNIX

Hello,

I faced this issues a few years ago and I'd like to give my contributions.
The easy and clean way I've found:

----------------------------------------------------------------------
<--> One installation for each mysql instance

<--> On each instance you can have as many databases as you want.

<--> One different mysql user and homedir (mysql41,mysql50) for each mysql installation.

<--> Put .my.cnf file in the home directory of each mysql user with the right parameters (different ports and socket files at least, this is the way I have found not to conflict between instances)
Ex:
:-----.my.cnf------------:
# The MySQL server
[mysqld]
port = 3515
socket = /tmp/mysql5015.sock
skip-locking
key_buffer = 256M
max_allowed_packet = 1M
:-------------------------:

<--> Start each mysql instance with his own user
----------------------------------------------------------------------


In this way I have several MySQL server instances (from 3.23 to 5.x) wonderfully working on the same 2.7 Solaris machine.

Aloha!

Claudio Nanni

-----Messaggio originale-----
Da: Eramo, Mark [mailto:meramo@hbs.edu]
Inviato: martedì 29 aprile 2008 15.54
A: Arthur Fuller
Cc: mysql@lists.mysql.com
Oggetto: RE: Starting a 2nd MySQL instance on UNIX

Hi Arthur,
Sure, no problem!

This actually proved to be rather tricky because the first instance was installed in /usr/local/mysql. It seems that by default, MySQL looks for things in this locations so if you deviate from it, you have to be explicit with mysql and tell it where to look for things. My new MySQL 50 instance had to run alongside the 4.0.20 instance so I installed it into /usr/local/mysql-50

** Here is a summary of things I had to do to bring this up properly **

I created a my.cnf and put it in /usr/local/mysql-50

In the my.cnf, I defined the following (The first entry is for the mysql program and the 2nd entry is for the mysqld program).

[mysql]
socket=/tmp/mysql50/mysql.sock
port=3307

[mysqld]
user=mysql5
pid-file=/usr/local/mysql-50/mysql50.pid
log=/usr/local/mysql-50/mysql50d.log
port=3307
max_allowed_packet=32M <== I had to set this so I could import the MySQL 4.0.20 database properly. Some users may not need this set as high.
socket=/tmp/mysql50/mysql.sock

#Path to installation directory. All paths are usually resolved relative to this.
basedir="/usr/local/mysql-50"

#Path to the database root
datadir="/usr/local/mysql-50/data"

You have to be careful to not only pick a separate port, but also a separate pid file for the process ID and a separate socket file, especially ifyou are running both instance at the same time.

I modified the mysql.server in the /support-files folder. I had to set the basedir and the datadir. I then copied this to the /bin folder.

I edited the mysql_install_db file in the /scripts folder and set the basedir and datadir. I then ran that to create the mysql database.

As root, I started the server ./bin/mysql.server start (The server starts up ). Since the user mysql50 is defined in this script, it then starts mysqld as the mysql50 user.

Now, the tricky part, to run mysql and access the mysql database, you cannot just say mysql -u root -p mysql, it will try to connect to the default instance in /usr/local/mysql.
What you have to do is:

Mysql --defaults-file=/usr/local/mysql-50/my.cnf -u root -p mysql

This now properly connects to the new mysql50 instance. Also, if you wantto run mysqladmin, you need to specify the --defaults-file option. Makesure wherever you use the --defaults-file option that it is the FIRST command line option used.

It took me quite some time to get this all working but now, I understand MySQL much better. I hope this proves to be some help to you and others out there who may be going through the same thing.

Regards,
Mark




From: Arthur Fuller [mailto:fuller.artful@gmail.com]
Sent: Tuesday, April 29, 2008 9:29 AM
To: Eramo, Mark
Cc: mysql@lists.mysql.com
Subject: Re: Starting a 2nd MySQL instance on UNIX

Would you kindly supply the changes you made, for our collective education? Thanks.

Arthur
On Mon, Apr 28, 2008 at 11:54 AM, Mark-E <meramo@hbs.edu<mailto:meramo@hbs.edu>> wrote:

Hi Ian,
Thanks for the reply. I was specifying the new port of 3307. I actually
got it working over the weekend. Turns out I had to add a few entries in the
mysqld section of the my.cnf file and I was able to connect.

Regards,
Mark



"Questo messaggio ed ogni suo allegato sono confidenziali e possono essere riservati o, comunque, protetti dall'essere diffusi. Se il ricevente non é il destinatario diretto del presente messaggio, é pregato di contattare l'originario mittente e di cancellare questo messaggio ed ogni suo allegato dal sistema di posta. Se il ricevente non é il destinatario diretto del presente messaggio, sono vietati l'uso, la riproduzione e la stampa di questo messaggio e di ogni suo allegato, nonché ladiffusione del loro contenuto a qualsiasi altro soggetto"
*****
"This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient,please contact the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not use, copy or print this message or attachment or disclose the contents to any other person."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:49 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145