0% found this document useful (0 votes)
136 views1 page

How To Install MySQL On Mac With Apple M1 Chip? - A Step-By

Technical guide to MySQL installation on Mac with Apple M1 chip

Uploaded by

patamlokong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views1 page

How To Install MySQL On Mac With Apple M1 Chip? - A Step-By

Technical guide to MySQL installation on Mac with Apple M1 chip

Uploaded by

patamlokong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SQLPad Questions % AI Tools % Pricing Blog Courses Certifications Light Dark $ Sign In

! Blogs " How to install MySQL on Mac with Apple M1 chip?

Table of Contents
How to install MySQL on Mac with Apple M1
chip? Step 1: Install Homebrew

Step 2: Install the latest MySQL server


SQL Last updated: 17 Dec 2023 5 mins read Leon
Step 3: Turn on the MySQL server
automatically.

Step 4: sign in and play with the newly


Welcome to this detailed tutorial, where I'll guide you through the process of installing and installed MySQL server
configuring MySQL on your Mac with Apple Silicon, whether it's an M1, M2, or the latest
Step 5: update my.cnf to improve MySQL
M3 chip. performance

The official MySQL documentation points you towards using the Native Package, which Share this article:

can be a bit complex, especially if you're new to Mac.


# " #

Based on my experience, I suggest we bypass that route and go with a smoother, more
user-friendly approach.
$ Subscribe

We'll utilize the wonderful Homebrew package manager, which simplifies everything from Skip the coding hassle!
Get analytics reports and
installing MySQL to future upgrades and database migrations. presentations in Minutes! No
coding needed, just instant
results.

Ready to dive in? Let's get started. GRAB YOUR FREE ANALYTICS REPORT NOW!

Step 1: Install Homebrew


Homebrew is a great package manager that makes it easy to install and uninstall software
(especially for open-source tools)

Visit https://brew.sh/ to follow the step-by-step instructions, or copy and paste the
following command into your terminal (iTerm 2 you just installed).

Copy

1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install the latest MySQL server


Copy

1 brew install mysql

Homebrew will always search for the latest version of a formula; as of Nov 7, 2023, the
latest MySQL version is 8.1.0

After a few seconds, you should see a success and instructions message.

leon $ brew install mysql


==> Downloading https://ghcr.io/v2/homebrew/core/mysql/manifests/8.0.31
Already downloaded: /Users/leon/Library/Caches/Homebrew/downloads/eeb7708d75e293e371d52ef35b6688a9ccb547d1c84c5bfd48
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/manifests/8.0.31
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/blobs/sha256:73a817585b4aa253b0984698b6e2d2fde197332d3de14485
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:73a817585b4aa253b0984698b6e2d2f
######################################################################## 100.0%
==> Pouring mysql--8.0.31.arm64_ventura.bottle.tar.gz
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
mysql -u root

To restart mysql after an upgrade:


brew services restart mysql
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/mysql/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql

Step 3: Turn on the MySQL server


automatically.
Copy

1 brew services start mysql

The MySQL server will automatically run in the background when you restart your Mac.

Step 4: sign in and play with the newly


installed MySQL server
On your command line, type

Copy

1 mysql -u root

mysql is a command-line utility that was installed together with the MySQL server, -
u specifies which user to login. By default, you, as the admin of your machine, can log in
as a 'root' user.

You should see something like the following:

leon $ mysql -u root


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.31 Homebrew

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

You can run some basic commands to find existing default databases and tables

Copy

1 mysql> show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)

Copy

1 mysql> use mysql;

Reading table information for completion of table and column names


You can turn off this feature to get a quicker startup with -A

Database changed

Copy

1 mysql> show tables;

+------------------------------------------------------+
| Tables_in_mysql |
+------------------------------------------------------+
| columns_priv |
| component |
| db |
| default_roles |
| engine_cost |
| func |
| general_log |
| global_grants |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| password_history |
| plugin |
| procs_priv |
| proxies_priv |
| replication_asynchronous_connection_failover |
| replication_asynchronous_connection_failover_managed |
| replication_group_configuration_version |
| replication_group_member_actions |
| role_edges |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+------------------------------------------------------+
37 rows in set (0.00 sec)

And Type \q to exit the database console.

To switch to a different database, type use <other_db_name>

Step 5: update my.cnf to improve MySQL


performance
By default, your newly installed MySQL server is using default settings, but if you prefer a
fast database, you can fine-tune it and change the parameters.

First, we need to locate the file in your command line, and type the following in your
terminal.

Copy

1 mysql --verbose --help | grep my.cnf

You will see something like the following:

Copy

1 order of preference, my.cnf, $MYSQL_TCP_PORT,


2 /etc/my.cnf /etc/mysql/my.cnf /opt/homebrew/etc/my.cnf ~/.my.cnf

You can search MySQL fine tuning on google and read more details:

For example:

https://haydenjames.io/mysql-8-sample-config-tuning/

https://github.com/Releem/awesome-mysql-performance

https://severalnines.com/blog/mysql-performance-cheat-sheet/

After that, you can update the config file.

Open the config file (it may require sudo privelege):

Copy

1 sudo vim /etc/my.cnf

Paste the following into the empty file:

Copy

1 [mysqld]
2 disable-log-bin = 1
3 skip-name-resolve = 1
4 performance-schema = 0
5 local-infile = 0
6 mysqlx = 0
7 bind-address = [IPs removed]
8 default-storage-engine = InnoDB
9 open_files_limit = 200000
10 max_allowed_packet = 256M
11 sql_mode = "STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
12
13 innodb_dedicated_server = 1
14 innodb_buffer_pool_instances = 48
15 innodb_log_buffer_size = 64M
16 innodb_read_io_threads = 12
17 innodb_write_io_threads = 12
18 innodb_stats_on_metadata = 0
19 innodb_file_per_table = 1
20
21 max_connections = 500
22 thread_cache_size = 128
23 table_definition_cache = 65536
24 table_open_cache = 65536
25
26 wait_timeout = 10
27 connect_timeout = 5
28 interactive_timeout = 30
29
30 tmp_table_size = 128M
31 max_heap_table_size = 128M
32
33 read_buffer_size = 256K
34 join_buffer_size = 1M
35 sort_buffer_size = 512K
36 read_rnd_buffer_size = 512K
37
38 slow-query-log = 1
39 long_query_time = 2
40 slow_query_log_file = /var/log/mysql_slow_query.log
41 log-error = /var/log/mysql/db.[removed].com.err

Source: https://haydenjames.io/mysql-8-sample-config-tuning/

Finally, we need to save the file and restart the MySQL server:

Copy

1 brew services restart mysql

And the following success message:

Stopping `mysql`... (might take a while)


==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

Since many variables impact the performance of your MySQL server and explaining those
factors is beyond the scope of this article, if you are interested to know more, please feel
free to read the following articles:

https://severalnines.com/blog/mysql-performance-cheat-sheet/

Congratulations, now you have a well-performed MySQL server on your Mac.

Eager to experiment with MySQL without installing on your machine? Dip your toes into
SQLPad's MySQL Playground, where you can play with real data, completely free of
charge.

Begin Your SQL, R & Python Odyssey

Elevate Your Data Skills and Potential Earnings


Master 230 SQL, R & Python Coding Challenges: Elevate Your Data Skills to Professional Levels with Targeted Practice and Our Premium Course Offerings

! Get My Dream Data Job

Related Articles All Articles

SQL 9 Nov 2023

PostgreSQL vs MySQL
SQL 6 Jan 2024 SQL 13 Jan 2024
Explore an in-depth comparison of PostgreSQL
vs. MySQL. Understand their histories,
How to install Postgres on a Mac M1 Top SQL IDEs in 2024
architectures, performance metrics, and ideal
with Homebrew in 5 minutes Discover the top 11 SQL IDEs in 2024 for data use-cases.
Effortlessly install Postgres 14 on Apple Silicon engineers, with detailed analysis of features,
(M1, M2, M3) Macs using Homebrew. This guide pros, cons, and pricing to help you choose the
includes configuration tips for enhanced perfect to
performance.

Resources Resource External Links Free AI Tools


Design and Development tips in your
inbox. Every weekday.
About Leetcode AI Data Analytics 2 Week Notice Letter
Generator
ADS VIA CARBON Candidate Screening HackerRank AI Infographics
Bulletproof Excuses to
Career Mode AI Data Chat
SQLPad transforms your data career by boosting your Get Out of Work
productivity tenfold as a data scientist, data engineer, Certification Privacy Run Python in Browser Generator
or data analyst. Master essential skills like R, SQL and Contact Terms of Service Book Recommendations Employee of the Month
Python, or confidently ace your job interviews. Join by Top Influencers Letter Generator
SQLPad Free today! FAQ
All Things Apple Vision Happy Birthday Message
Forum
#3 PRODUCT OF THE WEEK Pro for Coworker Generator
Education Hackathon
AI Posture Reminder App LinkedIn Bio Generator
Join Our Affiliate
LinkedIn Headline
Product News Generator

MySQL Playground LinkedIn Summary


Generator
PostgreSQL Playground
Thank you letter
Python Playground
Generator
R Playground
Thank you letter after
SQL Cookbook interview subject line
Generator

2024 SQLPad , All Rights Reserved " #

You might also like