On my previous post I posted the commands I used to create a brand new Linux web server for my Drupal site. Now I’ll post the commands to create the database server. While creating the server instance at RackspaceCloud, I’ve chosen Fedora 12 for my db server, which comes with MySQL 5.1.42.
-
# Install MySQL
-
yum -y install mysql mysql-server rsync
-
/sbin/chkconfig –levels 235 mysqld on
-
-
# Start DB
-
/etc/init.d/mysqld start
-
-
# Grant permissions to db_user (1.2.3.4 is the web server IP address)
-
mysql -e "grant all privileges on db_name.* to db_user@'1.2.3.4' identified by 'password';"
-
mysql -e "flush privileges;"
-
-
#############################################################
-
# FIREWALL
-
# Open DB port 3306
-
# Allow connections only from web server
-
iptables -F
-
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
-
iptables -P INPUT DROP
-
iptables -P FORWARD DROP
-
iptables -P OUTPUT ACCEPT
-
iptables -A INPUT -i lo -j ACCEPT
-
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-
iptables -A INPUT -s 1.2.3.4 -p tcp –dport 3306 -j ACCEPT
-
iptables -L -v
-
service iptables save
As easy as that, having a MySQL server up and running is piece of cake :)