having fun with code

CloudServers: Creating a new MySQL db server

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.

  1. # Install MySQL
  2. yum -y install mysql mysql-server rsync
  3. /sbin/chkconfig –levels 235 mysqld on
  4.  
  5. # Start DB
  6. /etc/init.d/mysqld start
  7.  
  8. # Grant permissions to db_user (1.2.3.4 is the web server IP address)
  9. mysql -e "grant all privileges on db_name.* to db_user@'1.2.3.4' identified by 'password';"
  10. mysql -e "flush privileges;"
  11.  
  12. #############################################################
  13. # FIREWALL
  14. # Open DB port 3306
  15. # Allow connections only from web server
  16. iptables -F
  17. iptables -A INPUT -p tcp –dport 22 -j ACCEPT
  18. iptables -P INPUT DROP
  19. iptables -P FORWARD DROP
  20. iptables -P OUTPUT ACCEPT
  21. iptables -A INPUT -i lo -j ACCEPT
  22. iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
  23. iptables -A INPUT -s 1.2.3.4 -p tcp –dport 3306 -j ACCEPT
  24. iptables -L -v
  25. service iptables save

As easy as that, having a MySQL server up and running is piece of cake :)

Related Posts:

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Additional comments powered by BackType

About the blog

This is a blog about development, focused mainly on Javascript but also other languages like python, shell scripts and more.

About the author

Eneko Alonso is a software engineer and UI developer with more than eight years of experience in software and web development. He lives in San Luis Obispo, California and works at LEVEL Studios.

Contact Info

Contact Info