Thursday, 31 January 2008

fedora yum mysql install guide

Here is a basic setup guide for installing mysql on a fedora systemusing the package manager yum.

First thing's first, you need to download and install mysql with the following command;

#> yum install mysql mysql-server mysql-devel

Next, open up your firewall on port 3306 - that's the port external connections (like mysql administrator) use to interact with the database.

#> vi /etc/sysconfig/iptables

Press i (to enter insert mode) and add these lines in an appropriate place;

-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 3306 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state -m udp --dport 3306 --state NEW -j ACCEPT

Press esc to stop insert mode.
Type :wq

Next restart your firewall for the settings to take effect;

#> service iptables restart

Now navigate to the default mysql-server document directory, and edit the example large confige file for mysql;

#> cd /usr/share/doc/mysql-server-*/
#> vi my-large.cnf

Press esc
Type :w!/etc/my.cnf
Type :q

You have now overwritten your basic configuration file for mysql server. Once you have restarted the mysqld service (using #> service mysqld restart), these settings should now take effect and you should have the mysql service listening on port 3306.

However, you still require a mysql database user who can access the database from an external computer (using mysql administrator) and you also need to set your root password. For the sake of simplicity and to get you connected, i'm going to use the root user in mysql, however I would recomend you use different users to manage your server for security reasons.

Anyway, here's how to set the root password;

#> mysql -u root

use mysql
update user set Password=PASSWORD('yourpassword') where User like '%root%';

Finally, restart the mysql service, for everything to take effect;

#> service mysqld restart

Voila, a workin mysql server which you can connect from external computers to port 3306 on your server.