cd /usr/local/ # 授权 sudo chown -R root:wheel mysql
安装
1 2
cd mysql/ sudo bin/mysqld --initialize --user=mysql
注意需要记住生成的临时密码: *比如以下生成的临时密码为:bG6ScrBzIs,: *
1 2 3 4 5 6 7
2019-02-16T05:48:25.030497Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-02-16T05:48:25.032220Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive 2019-02-16T05:48:25.133933Z 0 [Warning] InnoDB: New log files created, LSN=45790 2019-02-16T05:48:25.153377Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2019-02-16T05:48:25.208728Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 79fb336e-31ae-11e9-9ba5-3791334bdd72. 2019-02-16T05:48:25.326245Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2019-02-16T05:48:25.327408Z 1 [Note] A temporary password is generated for root@localhost: bG6ScrBzIs,: // 这里
sudo /usr/local/mysql/support-files/mysql.server status
配置启动别名
编辑配置文件:
1
sudo vi ~/.bash_profile
写入以下内容:
1 2 3 4
alias mysql-start='sudo /usr/local/mysql/support-files/mysql.server start' alias mysql-stop='sudo /usr/local/mysql/support-files/mysql.server stop' alias mysql-restart='sudo /usr/local/mysql/support-files/mysql.server restart' alias mysql-status='sudo /usr/local/mysql/support-files/mysql.server status'