Home / Articles / BSD / FreeBSD / Install MySQL server on FreeBSD

Install MySQL server on FreeBSD

Install MySQL server on FreeBSD
Install MySQL server on FreeBSD
  • Currently 4.5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 4.5/5 (3 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


Just follow few steps to configure it.

Install MySQL from ports

Before you start to install MySQL server, you need to add the following lines to /etc/make.conf file:

WITH_CHARSET=utf8
WITH_COLLATION=utf8_general_ci
BUILD_OPTIMIZED=yes
BUILD_STATIC=yes

The lines above sets default charset for MySQL and make an optimization of MySQL server for your system.

cd /usr/ports/databases/mysql51-server
make install clean

Configure MySQL server

Configure MySQL to start automatically at system startup. Add this line at the end of file /etc/rc.conf file:

mysql_enable="YES"

Then you need to choose an option file which suits your system needs. MySQL has a four of them which located in the /usr/local/share/mysql directory. Each of these option files is tailored to a specific system configuration as follows:

  • my-small.cnf is for systems with up to 64MB of RAM
  • my-medium.cnf is for systems with up to 128MB of RAM (ideal for web servers)
  • my-large.cnf is for systems with 512MB of RAM (dedicated MySQL servers)
  • my-huge.cnf is for systems with 1 to 2GB of RAM (datacenters, etc.)

Decide which one of them is the best choice for you system needs, and then copy it to the /usr/local/etc folder. Here is example:

cp /usr/local/share/mysql/my-huge.cnf /usr/local/etc/my.cnf
cd /usr/local/etc
chmod 0444 my.cnf

If you intend to use MySQL solely for web-based PHP applications, disabling TCP networking can make your MySQL installation a bit more secure.

Note: this only applies if your web server and MySQL database are operating on the same computer.

Uncomment or add this to /usr/local/etc/my.cnf file:

skip-networking 

Then restart MySQL to apply changes:

/usr/local/etc/rc.d/mysql-server start

Set password for root in MySQL

mysqladmin -u root password 'localpassword'


Read also

Install Apache in FreeBSD

Install Apache in FreeBSD

Discussion (total 3 comments)

Sergey Opalenik
Sergey Opalenik
June 05, 2012 at 01:27 am
/etc/make.conf file

where i can find it ? (directory)
Administrator User
Administrator User
June 05, 2012 at 03:01 pm
For default the file make.conf doesn't exist in /etc directory, you need to create it. The default options and their values for this file can be taken from /usr/share/examples/etc/make.conf.
Wellington Torrejais da Silva
March 13, 2013 at 07:44 am
Thank you for this article. This information it's very important...

Log in or create a user account to post a comment.

easyos.net
117217982212577402640

Quick navigation

General navigation