Install MySQL server on FreeBSD
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:
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:
Then restart MySQL to apply changes:
Set password for root in MySQL
mysqladmin -u root password 'localpassword'