Tuesday, March 11, 2008 at 11:55 am by Brady Wilson
Installing MySQL4 and MySQL5 on a single FreeBSD 6.2 Server.
This write-up makes the following assumptions:
- Working copy of FreeBSD 6.2.
- Build: 6.2-RELEASE.
Which should work on 6.2-STABLE and 7.0 as well.
Please let me know if you run into typos or other technical issues when implementing this.
- Download the latest binaries from mysql.com.
- Install MySQL 4.
- Install MySQL 5.
- Start the daemons.
- Post installation configuration.
At write-up time this was:
mysql-5.0.45-freebsd6.0-i386.tar.gz
mysql-standard-4.1.22-unknown-freebsd6.0-i386.tar.gzUncompress the binary source.
# cd /usr/local
# gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
# ln -s full-path-to-mysql-VERSION-OS mysql4Create the daemon user and group.
# pw groupadd mysql4
# pw useradd -n mysql4 -c "" -g mysql4 -d /nonexistent -s /usr/sbin/nologinSet the file permissions.
# cd /usr/local/mysql4
# chown -R root:mysql4 .Run the setup database setup script.
# scripts/mysql_install_db --user=mysql4Copy the startup script to the proper location.
# cp /usr/local/mysql4/support-files/mysql.server /usr/local/etc/rc.d/mysql4.server.shChange two variables in the start script.
# pico /usr/local/etc/rc.d/mysql4.server.shChange “basedir=” to “basedir=/usr/local/mysql4″
Change “datadir=/usr/local/mysql/data” to “datadir=/usr/local/mysql4/data”
Change “pid_file=” to “pid_file=/var/run/mysql4/mysql4.pid”
Create configuration files.
Copy one of the sample configuration files based on your server usage replacing xxxx in the line below.
# cp /usr/local/mysql4/support-files/my-xxxx.cnf /usr/local/mysql4/data/my.cnfChange variables in the configuration file.
# pico /usr/local/mysql4/data/my.cnfAdd a variable at the top of the [mysqld] section - “user = mysql5″
Change the “port = 3306″ variables to “port = 3304″
Change the “socket = /tmp/mysql.sock” variables to “socket = /tmp/mysql4.sock”
Create a run directory for the MySQL 4 process and set permissions on it.
# mkdir /var/run/mysql4
# chown -R mysql4:mysql4 /var/run/mysql4Uncompress the binary source.
# cd /usr/local
# gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
# ln -s full-path-to-mysql-VERSION-OS mysql5Create the daemon user and group.
# pw groupadd mysql5
# pw useradd -n mysql5 -c "" -g mysql5 -d /nonexistent -s /usr/sbin/nologinSet the file permissions.
# cd /usr/local/mysql5
# chown -R root:mysql5 .Run the setup database setup script.
# scripts/mysql_install_db --user=mysql5Copy the startup script to the proper location.
# cp /usr/local/mysql5/support-files/mysql.server /usr/local/etc/rc.d/mysql5.server.shChange a few variables in the start script.
# pico /usr/local/etc/rc.d/mysql5.server.shChange “basedir=” to “basedir=/usr/local/mysql5″
Change “datadir=” to “datadir=/usr/local/mysql5/data”
Change “pid_file=” to “pid_file=/var/run/mysql5/mysql5.pid”
Change “server_pid_file=” to “server_pid_file=/var/run/mysql5/mysql5.pid”
Change “user=mysql” to “user=mysql5″
Create configuration files.
Copy one of the sample configuration files based on your server usage replacing xxxx in the line below.
# cp /usr/local/mysql5/support-files/my-xxxx.cnf /usr/local/mysql5/my.cnfChange variables in the configuration file.
# pico /usr/local/mysql5/my.cnfAdd a variable at the top of the [mysqld] section - “user = mysql5″
Change the “port = 3306″ variables to “port = 3305″
Change the “socket = /tmp/mysql.sock” variables to “socket = /tmp/mysql5.sock”
Create a run directory for the MySQL 5 process and set permissions on it.
# mkdir /var/run/mysql5
# chown -R mysql5:mysql5 /var/run/mysql5# /usr/local/etc/rc.d/mysql4.server.sh start
# /usr/local/etc/rc.d/mysql5.server.sh startMySQL4:
Connect to MySQL
# /usr/local/mysql4/bin/mysql -u root -P3304 -S/tmp/mysql4.sockRemove the anonymous account.
mysql> DELET FROM mysql.user WHERE Host='localhost' AND User='';Set the root password
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('difficultpassword1');
mysql> SET PASSWORD FOR 'root'@'server.domain.com' = PASSWORD('difficultpassword1');Create a backupoperator account for backup script access to all databases.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'backupoperator'@'localhost' IDENTIFIED BY 'difficultpassword2';Apply changes.
mysql> FLUSH PRIVILEGES;Quit.
mysql> QUIT;MySQL5:
Connect to MySQL
# /usr/local/mysql5/bin/mysql -u root -P3305 -S/tmp/mysql5.sockRemove the anonymous account.
mysql> DROP USER '';Set the root password.
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('difficultpassword1');
mysql> SET PASSWORD FOR 'root'@'server.domain.com' = PASSWORD('difficultpassword1');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('difficultpassword1');Create a backupoperator account for backup script access to all databases
mysql> GRANT ALL PRIVILEGES ON *.* TO 'backupoperator'@'localhost' IDENTIFIED BY 'difficultpassword2';Quit
mysql> QUIT;That’s it! Create your mysql users and databases and connect your applications.
Notes:
Command line connections to mysql now require additional connection info to specify port and socket:
MySQL4 - # /usr/local/mysql4/bin/mysql -u username -ppassword -P3304 -S/tmp/mysql4.sock
MySQL5 - # /usr/local/mysql5/bin/mysql -u username -ppassword -P3305 -S/tmp/mysql5.sock
Remote connections to mysql will require specifying the correct port in the connection string instead of assuming port 3306.
Article Archives:
Smokeping on FreeBSD 7
This write-up assumes a working copy of FreeBSD 7.0. It was built using 7.0-RELEASE. It should work on FreeBSD 6.x-STABLE and future versions of FreeBSD 7. The package versions listed were current as of this writing but may have been updated by the time someone uses this howto.
This is a basic setup of Smokeping. There [...]
April 24th, 2008
opus:interactive garners new partnership with the MSP Alliance.
Who is the MSP Alliance?
The MSP Alliance’s accreditation program (MSAP) is the only best practices and standards-based program specifically created for the managed services industry.
The MSP Alliance is an organization who’s goal is to clarify the values and benefits of using Managed Service Providers, help companies improve the return on investment (ROI) in technology procurement [...]
February 26th, 2008
Put a Blade to these Servers and they bleed: for a cause.
February 5th, 2008
MCSE Boot Camp Studying Tricks & Tips
Looking for tips and tricks for passing your Microsoft Certified Systems Engineer exam? Take a moment and read this great entry that provides solid information that ensures that you will pass.
January 29th, 2008
Who’s keeping score?
I recently attended a Microsoft Certified Systems Engineer Boot Camp, put on by TECHPROS Group, in an attempt to obtain my MCSE. Yet, the certification wasn’t the only goal, I intended to meet all the criteria for the certification - in one week.
Back in August, I hopped on a plane from Portland, OR to [...]
December 9th, 2007
Article Comments: