Skip to content

Perl web development – Step 6: A Database

This is step 6 in the Perl web development series. In this step we install our MySQL database.

As we continue in our app development, we have come to the point where we need to be able to save data. Lists can’t be generated without having some data stored somehow, somewhere. For as far as this tutorial goes, we install a mysql database. Mind you, as writing this as a Mac user I will only discuss installation on a Mac. For other OS’s I recommend a simple google query in the form of “install mysql on <insert operation system here>”. There should be plenty of tutorials out there.

Homebrew

Homebrew is considered “The missing package manager for macOS”. With this program you can install packages on your mac without the hassle of embedding them thoroughly in your system. It’s like Perlbrew for distribution packages. To install Homebrew run:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This will run all the steps necessary to install Homebrew. All set? Ready to install our mysql server.

Install MySQL database

With Homebrew installing packages is a breeze. Homebrew makes use of a certain format to install packages called recipes. Every recipe runs a couple of command to make sure you have all the requirement needed and installs the package. First you have to make sure your installation is up to date

brew update
brew doctor
brew upgrade

Your installation is up to date now, run

brew install mysql

After that your installation should be complete. Run

mysql.server restart
and your mysql server should be up and running. Confirm by running
mysql -u<username> -p<password>
-p password should only be provided when you actually set a password.

If you can enter the mysql prompt you know your installation is properly setup. It’s easier to manage your databases running a program from your computer. For a Mac I can recommend the excellent Sequel Pro. It does exactly what I need and nothing more. It could be of great help for you. For other OS’s I recommend googling around a little bit.

Published inCode