
In This article I’ll describes how to install very famous and popular relational database, especially using as a back-end database for most web servers.
This article will not teach you how to use SQL. Our consideration go trough only for Installation.
We’ll use freebsd ports to install mySQL so before this we should update our ports tree. Again I will not discuss about how to update ports tree.
BUILD_STATIC=yes as per mySQL documentation building as static is suppose to improve mySQL performance.
BUILD_OPTIMIZED=yes and for compiler speed optimization we will use this flag. So we need to edit /etc/make.conf to set these options.
Now edit /etc/make.conf file and add these options.
.if ${.CURDIR}=="/usr/ports/databases/mysql51-server"
BUILD_OPTIMIZED=yes
BUILD_STATIC=yes
.endif
Now every thing is configured time to install mysql as mentioned above we will install mysql through ports so just change your directory to /usr/ports/databases/mysql51-server
cd /usr/ports/databases/mysql51-server/ make install clean
After sucessfully installation we need to copy my.cnf sample file into /etc/my.cnf
cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf chown root:sys /etc/my.cnf chmod 644 /etc/my.cnf
To start MySQL through freebsd script edit /etc/rc.conf file and add this line.
mysql_enable="YES"
Now we need to Install default mySQL database and start mysql server.
mysql_install_db chown -R mysql:mysql /var/db/mysql /usr/local/etc/rc.d/mysql-server start
mySQL will start with blank root password so first we need to secure or database server.
Change mySQL root password
mysql> SET PASSWORD FOR root@localhost=PASSWORD('yourpass');
Now delete illegal users and there privileges:
mysql> use mysql; mysql> delete from db; mysql> delete from user where not (host="localhost" and user="root"); mysql> flush privileges;
That is you have successfully installed and configure mySQL server. Your comments on this article will be very helpful for us.

Thanks for your article. It’s very simple to foloww and useful.
regards,
awesome tutorial, had some problems at first because I wasnt running the commands as root (duh). but i figured it out and got mysql set up. THANKS!
great howto