MySQL Tutorials - Herong's Tutorial Examples - v4.46, by Herong Yang
Install MySQL Database Server on macOS
This section provides a tutorial on how to install MySQL database server on macOS.
MySQL database server is a good alternative to Oracle and SQL Server, if you are looking for a free database server. Here is what I did to install MySQL database on macOS.
1. Go to MySQL download Website at https://dev.mysql.com/downloads/mysql/.
2. Click "Download" next to "macOS 10.14 (x86, 64-bit), DMG Archive". Enter your Oracle login name and password to start the download.
3. Double-click the download file mysql-8.0.17-macos10.14-x86_64.dmg in the Downloads directory to start the installation.
4. Select "Legacy password encryption" to avoid trouble using the new password encryption method.
5. Set the root password to "TopSecret", and follow instructions to finish.
6. Verify the MySQL server daemon with the "ps" command:
herong$ sudo ps -ef | grep mysqld 74 94827 1 0 9:35PM 0:01.73 /usr/local/mysql/bin/mysqld \ --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data \ --plugin-dir=/usr/local/mysql/lib/plugin --user=_mysql \ --log-error=/usr/local/mysql/herong/mysqld.local.err \ --pid-file=/usr/local/mysql/herong/mysqld.local.pid \ --keyring-file-data=/usr/local/mysql/keyring/keyring \ --early-plugin-load=keyring_file=keyring_file.so \ --default_authentication_plugin=mysql_native_password
7. Connect to the MySQL server with the "mysql" client program:
herong$ /usr/local/mysql/bin/mysql -u root -p Enter password: TopSecret mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
9. To start/stop MySQL server with System Preferences tool:
System Preferences > MySQL > Start System Preferences > MySQL > Stop
10. To shutdown MySQL server with "mysqladmin" command:
herong$ /usr/local/mysql/bin/mysqladmin shutdown -u root -p Enter password: TopSecret
Table of Contents
MySQL Introduction and Installation
Introduction of MySQL Programs
Perl Programs and MySQL Servers
Java Programs and MySQL Servers
Character Strings and Bit Strings
Table Column Types for Different Types of Values
Using DDL to Create Tables and Indexes
Using DML to Insert, Update and Delete Records
Using SELECT to Query Database
Window Functions for Statistical Analysis
Use Index for Better Performance
Transaction Management and Isolation Levels
Defining and Calling Stored Procedures
Variables, Loops and Cursors Used in Stored Procedures
System, User-Defined and Stored Procedure Variables
Storage Engines in MySQL Server
InnoDB Storage Engine - Primary and Secondary Indexes
Performance Tuning and Optimization
►Install MySQL Database Server on macOS
PHP mysqli_connect() Error on "localhost" on macOS
Installing MySQL Server on Linux