Our little project for today is setting up MySQL on FreeBSD. Installing MySQL via the FreeBSD ports sytem is a fairly painless process.
To get started login to your server with an SSH client and issue the following command.
[server][root][~]# portinstall mysql-server
You should be presented with different versions of MySQL to choose from. I chose to install the mysql50-server version. If you require a different version for some reason, then you will need to say “yes” to it instead.
Once everything gets compiled we need to setup a way to start MySQL when your server starts.
[server][root][~]# echo 'mysql_enable="YES"' >> /etc/rc.conf
Lets go ahead and start mysql so we can go about setting up the MySQL root password.
[server][root][~]# /usr/local/etc/rc.d/mysql-server.sh start
Everything should have started up ok for you at this point. Lets go ahead an login at the MySQL root user.
[server][root][~]# mysql -u root -p
You will be prompted for a password, hit enter since we have not setup the password yet. Enter the following and be sure to replace MyPassword with the password of your choosing.
SET PASSWORD FOR root@localhost=PASSWORD('MyPassword');
Thats all there is to it. Lets exit MySQL now and log back in to make sure everything worked before we continue.
exit
Now lets log back in with our new password. When you are prompted for a password this time, be sure to use the password that you set above.
[server][root][~]# mysql -u root -p
Hopefully everything worked out. If it didn't your in trouble.. well not really, but that how to is for another day :)
Now lets delete user accounts that do not have a username or any passwords. Type each of the 3 following commands (while you are logged into mysql as the root user) to delete insecure accounts and then type exit.
use mysql; delete from user where user=''; delete from user where host='localhost.localdomain';
And that's a wrap :)
Rails Server Setup:
Part 1: New Server Setup
Part 2: Setup FreeBSD 6.x
Part 3: FreeBSD Usability
Part 4: Setup FreeBSD To Use Blowfish
Part 5: Install and Setup PostgreSQL
Part 6: Install Lighttpd on FreeBSD
Part 7: Install MySQL 5.x on FreeBSD
Part 8: Install Ruby On Rails with FreeBSD