MySQL Development Setup – macOS Apple Silicon (ARM)
1. Download For Mac Apple Silicon (ARM64), download MySQL from the official MySQL website: MySQL Community Downloads – macOS ARM64 Required components: MySQL Community Server – Database server MySQL Workbench – Database management and development tool MySQL Shell – Optional, useful for advanced MySQL administration 2. MySQL Server Installation Install the downloaded MySQL Server .dmg package.…
This guide provides a step-by-step procedure for setting up a MySQL development environment on macOS using Apple Silicon (ARM) architecture. To begin, download the MySQL Community Server from the official MySQL website. The required components include MySQL Community Server, MySQL Workbench, and MySQL Shell.
After downloading the package, install the MySQL Server. Verify the MySQL binary by running `ls -l /usr/local/mysql/bin/mysql`. If the binary appears in the output, the installation was successful.
To ensure MySQL is accessible from the terminal, configure the PATH environment variable. For Zsh, add the following line to `~/.zshrc`: `export PATH=/usr/local/mysql/bin:$PATH`. Then, source the file by running `source ~/.zshrc`. For Bash, follow a similar process: add `export PATH=/usr/local/mysql/bin:$PATH` to `~/.bash_profile` and source the file with `source ~/.bash_profile`.
Verify the MySQL installation by checking the client and version. Use the command `which mysql` to find the location of the MySQL binary. Then, run `mysql --version` to confirm the installed MySQL version.
Once the MySQL server is installed and verified, connect to it using the root account. Use the command `mysql -u root -p` and enter the MySQL root password configured during installation. After logging in, execute `SELECT VERSION();` to confirm the MySQL server version.
For a graphical interface, install MySQL Workbench. Create a local connection with the hostname set to "127.0.0.1" and port set to "3306". Use the root username and password to test the connection.
To create a development database, connect to MySQL as root and execute `CREATE DATABASE dev_database;`. You can then verify the database exists with `SHOW DATABASES;` and select it using `USE dev_database;`.
For security purposes, create a separate database user for application development. Use the command `CREATE USER devuser @ localhost IDENTIFIED BY 'YourStrongPassword';` to create the user. Grant the necessary privileges with `GRANT ALL PRIVILEGES ON dev_database . * TO devuser @ localhost;`. Apply the privileges by running `FLUSH PRIVILEGES;`. Test the user by logging in with `mysql -u devuser -p dev_database`.
MySQL commands can be used to manage the database. To view available databases, use `SHOW DATABASES;`. To select a specific database, use `USE dev_database;`. List tables with `SHOW TABLES;`, describe a table's structure with `DESCRIBE table_name;`, check the current user with `SELECT USER();`, and view the server version with `SELECT VERSION();`. To exit MySQL, type `EXIT;`.
The MySQL installation is typically located at `/usr/local/mysql/`. The MySQL client binary is found at `/usr/local/mysql/bin/mysql`, and the MySQL configuration may be in `/etc/my.cnf` or `/usr/local/mysql/etc/my.cnf`, depending on the MySQL version and installation method.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.