Installing MySQL on FreeBSD
Posted by Eric Stein - June 24, 2006 CE @ 05:42:50 UTC
Installing MySQL isn't as simple as you would think on FreeBSD. You might think it's as simple as this:
To install the configuration file and databases, do this:
Once you're satisfied with configuration file (you may want to read through it and make some other changes), start up your shiny new MySQL server:
cd /usr/ports/databases/mysql51-server/
make install clean
But that isn't true. It does compile everything and install the binaries, but the configuration file and default databases are nowhere to be seen. If you've never installed MySQL before, this can be very irritating.make install clean
To install the configuration file and databases, do this:
cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
cp /usr/local/share/mysql/mysql.server /etc/rc.d/
mysql_install_db --user=mysql
chown -R mysql:mysql /var/db/mysql/
chmod 700 /var/db/mysql/
You can change the medium in my-medium.cnf to huge, large, or small (depending on how resource-hungry your application is). After you install the correct one for your needs, you may want to consider turning off remote access to the MySQL server. If all the applications that need to access your databases are going to be on the same system, this is desirable - the fewer possibly malicious clients have access, the better. To do this, uncomment the skip-networking line in the my.cnf file you just created.cp /usr/local/share/mysql/mysql.server /etc/rc.d/
mysql_install_db --user=mysql
chown -R mysql:mysql /var/db/mysql/
chmod 700 /var/db/mysql/
Once you're satisfied with configuration file (you may want to read through it and make some other changes), start up your shiny new MySQL server:
/etc/rc.d/mysql.server start
There's something about MySQL that has always bothered me - the complete and utter lack of an ability to set a root password BEFORE activating the server. Now you should set a root password, ASAP:mysqladmin -u root password
mysqladmin -u root -h `hostname` password
If you don't care about people possibly seeing your password while you set it via w or ps, you can also do it like this (which won't prompt you interactively):mysqladmin -u root -h `hostname` password
/usr/local/bin/mysqladmin -u root password 'new-password-here'
/usr/local/bin/mysqladmin -u root -h `hostname` password 'new-password-here'
If other people you don't absolutely trust have local access to your server (or you have left networking enabled for whatever reason), you might not be the first person to connect to the unsecured server and set the password. So hurry./usr/local/bin/mysqladmin -u root -h `hostname` password 'new-password-here'
Post a Comment