Using tar.gz to install mysql on mac


  • download:
  • MySQL reference document:

Environmental Science:

  • macOS Mojave 10.14.2


  • Administrator user, no new mysql user or group was created during this period

Installation kit:

  • mysql-8.0.13-macos10.14-x86_64.tar.gz

Installation configuration

1. decompression
After decompressing the downloaded tar.gz, move it to / usr/local/mysql. The directory structure is as follows:

$ pwd
$ tree mysql -L 1
├── LICENSE.router
├── README.router
├── bin
├── data
├── docs
├── include
├── lib
├── man
├── run
├── share
└── support-files

In fact, according to the specification of Unix directory structure, it is recommended to do so.
In my actual operation, I just created a soft link through sudo ln -s ${MYSQL_HOME} /usr/local/mysql.
Unzip command: tar -xzvf ${filename}

2. Modify permission: sudo chown -R usr:group /usr/local/mysql

3. initialization

$ cd /usr/local/mysql
$ bin/mysqld --initialize --user=ephemerid --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2019-01-20T05:50:19.601053Z 0 [System] [MY-013169] [Server] /Workspaces/programfiles/mysql-8.0.13-macos10.14-x86_64/bin/mysqld (mysqld 8.0.13) initializing of server in progress as process 1045
2019-01-20T05:50:19.603274Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2019-01-20T05:50:21.143953Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: A_mBvrbnD0*r
2019-01-20T05:50:22.000946Z 0 [System] [MY-013170] [Server] /Workspaces/programfiles/mysql-8.0.13-macos10.14-x86_64/bin/mysqld (mysqld 8.0.13) initializing of server has completed

ephemerid is my user name, changed to my own.
For the meaning of the latter two options, see the following MY-011011.
As mentioned earlier, I used the soft link, so I saw the actual directory of mysql in the console information.
Note the "A temporary password is generated for root@localhost"

5. boot

$ support-files/mysql.server start
Starting MySQL

6. Connect and change the initial password

$ bin/mysql -uroot -pA_mBvrbnD0*r
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

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

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'pass123456';
Query OK, 0 rows affected (0.02 sec)

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
4 rows in set (0.01 sec)

mysql> exit

!! Don't directly add the password after the - p option when entering the password. It will be seen. Be sure to pay attention to security!!!

The first time you log in, you will be prompted to reset your password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'pass123456';

7. Stop service

$ support-files/mysql.server stop
Shutting down MySQL


The server quit without updating PID file

When you start without initialization:

$ sudo ./support-files/mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/mysql/data/


Initialize, as mentioned above, mysqld --initialize


At initialization time, no valid mysql directory and mysql data directory were found.

$ sudo ./bin/mysqld --initaialize --user=ephemerid
2019-01-20T05:13:45.476844Z 0 [System] [MY-010116] [Server] /Workspaces/programfiles/mysql-8.0.13-macos10.14-x86_64/bin/mysqld (mysqld 8.0.13) starting as process 993
2019-01-20T05:13:45.480320Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /Workspaces/programfiles/mysql-8.0.13-macos10.14-x86_64/data/ is case insensitive
2019-01-20T05:13:45.487935Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2019-01-20T05:13:45.488090Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2019-01-20T05:13:45.488119Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-01-20T05:13:45.488808Z 0 [System] [MY-010910] [Server] /Workspaces/programfiles/mysql-8.0.13-macos10.14-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.13)  MySQL Community Server - GPL.


Two options are added, namely -- basedir and -- datadir mentioned above
To learn more, refer to:



Tags: MySQL sudo Oracle Unix

Posted on Mon, 02 Dec 2019 16:01:27 -0800 by pbaker