How to install XAMPP on Mac: Download the correct version of XAMPP; Run the installer with the default options; Launch XAMPP; Start the services; In this tutorial, I'll be using my Mac running macOS 10.14 ('Mojave'), but the steps are the same for the other versions of Mac OSX and macOS 10.x (update: I've tested this on Catalina and it works. Part 2: macOS 11.0 Big Sur Web Development Environment. In Part 1 of this 3-part series, we covered configuring Apache on macOS to work better with your local user account, as well as the installation process for installing multiple versions of PHP. In this Part 2, we will cover installing MySQL, Virtual Hosts, APC caching, YAML, and Xdebug. Localhost install on MacOS Catalina (mac mini 2012) running Mac Apache & PHP 7.3.22 + Homebrew MySQL 8.0.21 Apache is running, MySQL is running (I have accessed via command line and checked my username, password, and Privileges). I have confirmed that wp-config.php contains the same info as the database itself reports.
Question or issue on macOS:
I’m setting up my development environment in the new macOS Sierra .
$ brew install mysql $ brew tap homebrew/services $ brew services run mysql And everything start work until today, where I tried to run my local website (as any other day) and I got: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
First of all, I installed Rbenv, Ruby (2.3.1), Homebrew and so the latest version of MySQL (5.7.15).
Ok, MySQL was initialized. Time to install the mysql2 gem…
But it didn’t work. 😞
How to solve this problem?
Solution no. 1:
I just had the same problem, tried all of the solutions listed above, then commenced to bang my head against they keyboard for a couple of hours.
I then thought to try and install/reinstall the Xcode Command Line Tools:
Once I did that the mysql2 gem installed w/ no problems. I hope that does the trick!
Solution no. 2:
When you install openssl via brew, you should get the following message:
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you’ll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
You can set these build flags (for the local application) by running the following:
This worked for me.
See bundler’s documentation for more information.
Solution no. 3:
Lots of great answers, I was able to combine them into this:
because I was not comfortable with bundle config
Solution no. 4:
I am here to share my fix, since the other answers didn’t work.
For my environment, I need MySQL 5.6 so I had to use:
brew install mysql56
instead of brew install mysql
Bundle installing the mysql2 gem kept failing, until:
brew link mysql56
I also ran afterwards:
mysql.server start
The last step might be unnecessary, but just in case.
Solution no. 5:
With Mac OS 10.15 Catalina when I tried Alessandro’s fix the gem and extensions could be installed correctly but bundle install
failed. What worked was just:
without the cppflags
part.
Solution no. 6:
Here’s what worked for me.
Originally I ran:
then
I received an error in /Users/…/.bundle/ruby/2.5.0/extensions/x86_64-darwin-18/2.5.0/mysql2-0.5.3/mkmf.log :
clang: error: unsupported option ‘–with-cppflags=-I/usr/local/opt/openssl/include’
So I removed “–with-cppflags=-I/usr/local/opt/openssl/include”
Then ran:
followed by:
Which worked.
Solution no. 7:
Almost the same scenario as @Caio Tarifa, Ruby 2.3.3, mysql 5.6 and mysql2. Tried on couple of solutions above and finally make it work with @kylekeesling’s approach.
First, tried on solution 1 by @spickermann:
Nothing happened, same error shown.
Second, tried on solution by @Alessandro Berardi:
This got different but more errors since it overwrite gem extension’s config so all gem extension installation failed.
Finally, tried on @kylekeesling solution:
It fix mysql gem issue as well as nikogiri. Since I already intall Xcode, in my case it’s reinstall the Xcode Command Line Tools.
Solution no. 8:
Try installing xcode-select –install
Solution no. 9:
So I ran into this similar issue and for me it turned out to be a wrong ruby version and incompatible MySQL version. I use ruby 2.3 on most of my projects but inherited a 2.1 project. Changing to rvm to use 2.1 got me a little further.
Then I found this: https://github.com/brianmario/mysql2/issues/603 that said you had to use mysql2 gem version greater than 0.3.17 with MySQL version 5.7
Updated gem to 0.3.17 and it fired right up. Hope this helps someone.
Solution no. 10:
If none of the above works .. like in my case, doing this solved the issuebrew install openssl
FYI: i am using MacOS Catalina
Hope this helps!
What is MySQL Workbench?
MySQL Workbench is a GUI tool to manage your database. You can see the tables, records in the table, you can create a new schema, query, etc.
If you are more of a visual person who needs to deal with database (MySQL), MySQL Workbench is a very powerful and useful tool.
Before Installing MySQL Workbench on macOS
Before installing the MySQL Workbench, make sure you have access to the database. It is either db in your local system or it could be a remote database in your hosting server or even cloud database such as AWS RDS.
In this post, I will be using local MySQL server as an example. Please check out this post on installing MySQL server on your Mac.
Installing MySQL Workbench on macOS
Go to https://dev.mysql.com/downloads/workbench/
Click Download
to get the DMG installer
Once Installer is downloaded, double click the installer. When you double clicked, you should see the screen like below. Follow the instruction to drag the MySQL Workbench icon to the Application folder to complete the installation of MySQL Workbench into your system.
Launching the MySQL Workbench App
Once the MySQL Workbench is installed and when you try to open the app, you might see the message like below. Press Open to proceed on launching the application.
Once the start up screen shows up, you will see a connection already added (assuming you have installed local MySQL server)
Click the Local instance 3306
. It will ask for the password. Enter the password you entered when you set up the local MySQL server and press OK
. (You can check the Save password in keychain
. In this way you do not need to type the password every time you access to your database)
Creating the Schema
Now you have access to your local database server (MySQL server). You can start creating your own database. Schema is the main container of database where you put the tables. Let’s try to create a schema. Click the Create New Schema icon (highlight in below screenshot)
Assign some name on your new schema. In this example, let’s use test_db
as a schema name and press Apply
.
You will see a dialog box to review the SQL Script to execute by an app. Basically, it will execute an SQL statement of CREATE SCHEMA `test_db`;
Press Apply
to create a new schema.
Select Schemas
tab and verify the new schema is added.
Creating the Table
Once schema is created, you need to create a table to actually store the data in the “database”.
Expand the test_db
schema and right click on the table
.
Select Create Table...
Start entering values in the column section. This will be the identifier for the specific field in the database.
Enter the following entities in the table.
PK - Primary Key
. Usually the “id” will be your primary key.
NN - Not Null
. For entities, you don’t not want to have Null value (empty value) by the time the record is inserted. Put check on this if there is a specific entity you want have some value on it. For example, id entity must have a value always. So for id, put check on NN
.
UQ - Unique
. If the record entered in the table needs to be unique, put check on this. For example, “id” must be unique so that when you query for specific id, it will only return 1 result.
BIN - Binary
UN - Unsigned
ZF - ZeroFill
AI - Auto Increment
. For values you want to automatically increment, put check on this. Typically id should have auto increment on. So every time there is a new record added, the id value will auto increment.
G - Generated
Press Apply
and you will the above confirmation. Press Apply
again to add some records in your table.
Go to your schema, and expand the table. You should be able to see the table you just created.
Access to the Table
To view the table you created, go to the table you created.
Right click and select Select Rows - Limit 1000
At this point, the table has 0 record. This is expected since the table has just created.
Adding Sample Records
Once you have your table opened, you can directly add some records to it by simply double click the columns. Try entering the following records as an example and press Apply
.
Press Apply
to confirm the records you want to add in the table.
Note: You can leave the id column blank since this column is set to auto increment. It will automatically assign value as a new record is added.
Install Mysql Workbench Mac Catalina
Now you can see there are 2 records added in your table. You can see the id is automatically added in ascending value.
If you are using Big Sur on Apple’s new Silicon M1, checkout Using MySQL Workbench on macOS Big Sur blog post.