Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 3
Installing Apache 2.2, MySQL 5 and PHP 5 in FreeBSD 6.0 for a Reliable Web Server
Part 3 – Installing MySQL Server 5 with FreeBSD Ports Collection
- Login to the FreeBSD system as root, or su – root to get to super user environment.
- Enter the following commands at FreeBSD command line interface (CLI) (Wait till each command to finish processing before running the next command):
cd /usr/ports/databases/mysql50-server
make install clean
mysql_install_db --user=mysql
chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/
/usr/local/bin/mysqld_safe -user=mysql &Note: If you encounter Command not found error, use command rehash to update OS path environment variables.
- The port installation will put a script file mysql-server.sh in /usr/local/etc/rc.d which will has capability to start MySQL server. To enable MySQL server to start automatically after every FreeBSD server reboot, enter the following command in CLI:
echo ‘mysql_enable=”YES”‘ >> /etc/ rc.conf
- By default, MySQL default super user account – root – has no password (blank password). So it’s important to assign the administrator account password. To change the password to root user, enter the following command:
mysqladmin -u root password newpassword
Replace newpassword with your own desired password.
- Optionally, copy either my-huge.cnf, my-large.cnf, my-medim.cnf, my-small.cnf or my-innodb-heavy-4G.cnf (depending on the usage and utilization of MySQL server) as my.cnf to /var/db/mysql which will enable you to tweak and change the configuration of server-specific MySQL server options by editing the file.
- MySQL 5.0 installation done.
Related Articles
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 5
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 4
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 2
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 1
- Installing and Configuring DHCP Server (DHCPd) on FreeBSD
- Install phpBB 2 in Windows XP running on Apache 2, PHP 5 and MySQL 4
- Reset the Root Password of MySQL Server
- Change and Reset MySQL root Password
- FreeBSD Apache HTTP Accept Filter Error
- Checking Free Disk Space on FreeBSD Server










































August 21st, 2008 13:06
Hey there. I was having trouble with the “mysql_install_db: command not found” when installing FreeBSD 7. I ran the rehash command and then entered mysql_install_db again and it worked fine.
August 2nd, 2008 07:21
On FreeBSD 7.0 you don’t need to manually install the databases and set permissions, that is done in the startup script the first time it is run.
Just make sure you have
mysql_enable=”YES”
in /etc/rc.conf before you run mysql-server.
You could hence rewrite the install instructions to this:
cd /usr/ports/databases/mysql50-server
make install clean
echo ‘mysql_enable=”YES”‘ >> /etc/rc.conf
/usr/local/etc/rc.d/mysql-server start
March 23rd, 2008 02:39
the my-huge.cnf, my-large.cnf, my-medim.cnf, my-small.cnf or my-innodb-heavy-4G.cnf are found in /usr/local/share/mysql/
January 23rd, 2008 00:43
Where can I find these files on a MySql 5.1 install on FreeBSD 6.2?
my-huge.cnf, my-large.cnf, my-medim.cnf, my-small.cnf or my-innodb-heavy-4G.cnf
January 11th, 2008 10:32
great tutorial! thanks!
November 12th, 2007 16:33
rehash is a command to ‘refresh’ the system. Did it work after rehash.
November 12th, 2007 13:32
i ecountered the not found error while installing mysql, what should i do? and what is the command rehash actually is? thank you so much.
March 5th, 2007 21:25
Oh; and thanks for the great article!
March 5th, 2007 21:24
If you’re getting “mysql_install_db: Command not found.” after punching in “mysql_install_db”, you should try to cd to /usr/local/bin/ and then run “mysql_install_db”.
Cheers.
January 27th, 2007 02:06
Hi,
I have installed freebsd 5.5 and now with your guideline instructions I have install mysql, php5 and apache2.2.But i do not know how to configure a website so I can test that if it works.Please help me with a link who can provide step by step instuctions or refer me some good basic book.
Thanks.
September 12th, 2006 21:43
just delete
August 19th, 2006 15:10
rc.conf contains
mysql_enable=”YES”
apache22_enable=”YES”
here is results from mysqladmin -user admin
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists!
August 19th, 2006 11:25
Check if you can run mysqladmin or other mysql tools. Also make sure your “YES” in rc.conf is using proper “, as the ” in the article has been changed.
August 19th, 2006 10:45
Ive followed this guide but when i run “mysql-server.sh start” it returns starting mysql and does nothing else. i ran “mysql-server.sh status” and it returned “mysql is not running”
mysql_enable=”YES” is in rc.conf but is not starting. any help?
August 18th, 2006 00:57
The problem is that mysql (version 5.x) is not starting with mysql_enable=”YES” in /etc/rc.conf.
Im using FreeBSD v6.1.x. I do not have the space problem between enable and the “=”. The message I receive on bootup is “YES: notfound”.
Any suggestions welcome.
June 7th, 2006 13:14
you’re right changing it via phpmyadmin gave me the same result, so what i did was change some settings in the config.inc.php of phpmyadmin, change the auth_type = cookie and blowfish = mypassphrase and everything were fine.
June 6th, 2006 16:56
Did you flush privileges after changing the password? The problem may be due to hashing of MySQL password. May be you can try the following commands after resetting your root password if it cannot works:
mysql -u root mysql
> UPDATE user SET password=password(’secret’) WHERE user=’root’;
> flush privileges;
You may try phpmyadmin too, but I remembered I used to have exactly this same problem while phpMyAdmin didn’t help much. Do let me know how you solve it.
June 6th, 2006 14:32
i’ve tried all the options mentioned but none of them worked, so i did a fresh install again, before creating a password for mysql root user, i logged in as root and it worked fine, i was able to get a mysql shell but when i issue the command mysqladmin to create a password for root, i got an error, i tried to log in as root and wtf i’m back with the same problem. do u think i would be better off if i install phpmyadmin and change the root password from there?
June 6th, 2006 11:49
jan, may be you have set the password for root. Try to access mysql with -uuserid and -ppassword option. Or you can follow instruction here on how to change and reset your root password.
June 6th, 2006 11:08
i’m stucked with the mysql part of your howto, after issuing # mysqladmin -u root password newpassword, i issued # mysql -u root -p newpassword, i always get the access denied error. what did i miss?
thanks
May 21st, 2006 14:07
Thanks for pointing out, will update.
May 21st, 2006 13:12
mysql_enable =