How To Install MySQL Using Homebrew On Mac OS?

In this post, I will be walking you through how I installed MySQL on my MacBook Pro.

I, recently, purchased a MacBook Pro and this serves as the go to toy for all my programming stuffs that I do at home. Mac OS is fairly new to me and I wanted to install MySQL on it, to play with WordPress installations locally.

I will be using Homebrew to install MySQL on Mac OS. Homebrew is the package manager for Mac OS and I highly recommend it. If you are new to Homebrew, then I recommend that you read this post from Tutsplus before you continue reading further.

Now that you know what Homebrew is, let me show you, how I installed MySQL on Mac OS.

If you haven’t installed Homebrew already, on your Mac OS, you can follow the install instructions on Homebrew website to get Homebrew installed. Let’s brew it!

Step 01: Fire up the Terminal and execute brew doctor. This command checks for potential problems with Homebrew. You can ignore the warnings that you get when you run this command, but not errors.

Step 02: Now, run brew update to update Homebrew and all new formulae.

Formulae are instructions for Homebrew on how to install specific software and where to find the necessary files and dependencies.

Step 03: Now we can install MySQL by running the command brew install mysql. Now you can sit back and relax while Homebrew installs MySQL and it’s the dependencies.

Once installed, you can connect to MySQL using the command mysql -u root.

You can continue using local MySQL without a passowrd. But, I prefer to secure my local installation and in order to that, we can run the mysql_secure_installation command. Setting the password, from here on, is self explanatory.

Below are all the terminal commands needed for the complete installation of MySQL.

How To Add/Remove Multiple Attributes Using jQuery?

Are you using multiple jQuery statements to add or remove attributes to/from HTML elements? In this post, I’ll share with you, how you can achieve the same in one go.

Recently in one of the projects I was working on, I had to swap attributes between two HTML elements. So I was looking out to see if I could do it in a single statement rather than adding/removing one after the other. Guess what, jQuery has a way do it.

If you’re new to jQuery and looking to include jQuery in your project, you might want to checkout getting started with jQuery.

Let us set up the stage first. We shall include <input> elements. The class on the input elements should help you to identify what we’re about to do on that particular element.

Assuming you have jQuery loaded, let us use jQuery to add/remove multiple attributes.

First, let us remove the attributes id and name and then on the second input elemement, we shall add the id and the name attributes.

In order, to remove multiple attributes, use the .removeAttr() method and separate the attributes with a space. And, to add multiple attributes, we must use Plain Object of attribute value pairs in the .attr() method.

The PlainObject type is a JavaScript object containing zero or more key-value pairs.

You can find the full working demo from I hope you found this tutorial helpful.