Install Mysql On Mac Os


If you want to install MySQL on Lion it’s pretty easy, just head on over and download the DMG from (for lion you’ll need the 64bit DMG Archive).
Then double click on mysql package to install it, then on MySQLStartupitem.pkg, and then on the MySQL.prefPane. Once that’s done start it up via system prefs.

May 08, 2021 Mysql is a database management system, initial release happened in 1995 by ORACLE which is free and open source. Explore the opensource MySQL in Github. There are multiple ways to install on Mac OS, here we have listed the easiest Setup. Native Package Installer, which uses the native macOS installer (DMG) to walk you through the installation of MySQL. For more information, see Section 2.4.2, “Installing MySQL on macOS Using Native Packages”. According to the official MySQL website: Installing MySQL on OS X Using Native Packages Note Before proceeding with the installation, be sure to stop all running MySQL server instances by using either the MySQL Manager Application (on OS X Server). MySQL Shell 8.0 / Installing MySQL Shell / Installing MySQL Shell on macOS 2.3 Installing MySQL Shell on macOS To install MySQL Shell on macOS, do the following.

Finally, you will need to add ‘/usr/local/mysql/bin’ to your path environment. To do this, open up terminal and type in:

Or if you have textmate you can use:

Then just update the export PATH if there’s one already there, my file looks like this:

export PATH='$HOME/.rbenv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH'
eval '$(rbenv init -)'
PS1='[W:]$ '
alias ll='ls -lahG'
alias irbs='irb --simple-prompt'
alias rake='bundle exec rake'

Then save it. Rbenv already created the PATH so I just updated it. The PS1 line tells terminal to show the directory you are currently in as the prompt (you can always use ‘pwd’ to get the full path to working directory if you forget where you are). I’ve also added the alias to ll, which shows you all your files in the directory (including hidden files) with permissions, when you type in ll in terminal. The alias, irbs, will give you irb –simple-prompt, and the last one for rake, will use bundler.

If you want your terminal prompt to be in red, use the following instead:

Close the terminal window and restart it for changes to take effect, and now you should be able to type ‘mysql’ and get to MySQL.

Set root password for MySQL

It’s good practise to set your root password, here’s how:

mysql -u root
SET PASSWORD FOR [email protected]=PASSWORD('your_password_here');

Install MySQL gem for Ruby

If you’re using Ruby, simply open a terminal window and:

Enter your user password (not your mysql one) when asked.

If you get an ‘Library not loaded: libmysqlclient.18.dylib’ when doing your first rake db:migrate, you will need to add this to your .bash_profile

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

(Then simply close and open a new terminal window)

If that doesn’t work try running this in your terminal:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

All done 🙂

This is what my .bash_profile looks like btw, I’ll probably keep it updated in this post given I mention it above:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
export PATH='$HOME/.rbenv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH'
eval '$(rbenv init -)'
PS1='[W]$ '
alias ll='ls -lahG'
alias irbs='irb --simple-prompt'
alias rake='bundle exec rake'
alias bec='bundle exec cucumber'
alias ber='bundle exec spec'
alias pow='touch tmp/restart.txt'

Why not give PostgreSQL a go?

Since writing this guide I have moved to Postgres – it is a much better relational database and includes many features such as a nosql option, queueing, transactions plus lots more. It is also very fast and very stable – and now seems to be the database of choice for Rails developers. You can install easily by brew install postgresql (you can install it in addition to MySQL btw – so you don’t have to choose one or the other).

  1. Download the MySQL DMG for Mac OS X

  2. Install MySQL

Creating aliases for mysql and mysqladmin. However there are other commands that are helpful such as mysqldump. Instead, I updated my path to include /usr/local/mysql/bin.

Install Mysql On Mac Os


You will need to open a new Terminal window or run the command above for your path to update.

Install Mysql On Macos Homebrew

I also run mysql_secure_installation. While this isn’t necessary, it’s good practice.

Connect PHP and MySQL¶

You need to ensure PHP and MySQL can communicate with one another.

If you have /var/mysql/mysql.sock but no /tmp/mysql.sock then

Additional Configuration (optional)¶

The default configuration for Apache 2.4 on OS X Yosemite seemed pretty lean. For example, common modules like mod_rewrite were disabled. You may consider enabling this now to avoid forgetting they are disabled in the future.

I edited my Apache Configuration:

I uncommented the following lines (remove #):