今天在电脑macPro上面安装了Mysql5.7.17,以下是安装步骤,还有一些错误解决方法
系统版本:mac OS Sierra 10.12
MySQL 版本:5.7
安装方式:TAR.GZ
下载地址:下载地址
安装流程:
1.解压压缩文件(下载的文件放在Downloads)
fengsonglin:Desktop songlin$ cd /Users/用户名/Downloads
fengsonglin:Desktop songlin$ tar zxvf mysql-5.7.17-macos10.12-x86_64.tar.gz
移动解压后的二进制包到安装目录
fengsonglin:Desktop songlin$ sudo mv mysql-5.7.17-macos10.12-x86_64 /usr/local/mysql
更改所属组和用户
fengsonglin:local songlin$ sudo chown -R root:wheel mysql
切换到 mysql 安装目录并执行初始化命令并记录生成的临时 root 密码
fengsonglin:mysql songlin$ sudo bin/mysqld --initialize --user=mysql --explicit_defaults_for_timestamp
输出相关内容:2017-02-06T00:56:17.552419Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive 2017-02-06T00:56:17.708042Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-02-06T00:56:17.732202Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-02-06T00:56:17.786185Z 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: 1123c458-ec07-11e6-a42d-05e7779eb19f. 2017-02-06T00:56:17.800555Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2017-02-06T00:56:17.801159Z 1 [Note] A temporary password is generated for root@localhost: irTPVktgy0#C临时密码
MySQL的启动,停止和状态检查
cd /usr/local/mysql
启动
sudo support-files/mysql.server start
重启
sudo support-files/mysql.server restart
停止
sudo support-files/mysql.server stop
检查 MySQL 运行状态
sudo support-files/mysql.server status
修改密码
需要 MySQL 服务在运行状态执行
cd /usr/local/mysql/bin
./mysqladmin -u root -p password 新密码
输入生成的临时密码↵
查看数据库
需要 MySQL 服务在运行状态执行
cd /usr/local/mysql/bin
mysql -u root -p
输入修改后的密码
使用数据库
mysql> use mysql
退出
mysql> quit
@note 在启动的过程之后出现这个错误
.Logging to '/usr/local/mysql/data/fengsonglin.local.err'.
. ERROR! The server quit without updating PID file (/usr/local/mysql/data/fengsonglin.local.pid).
原因有如下几种可能:
1.可能是/usr/local/mysql/data/fengsonglin.local.pid文件没有写的权限
解决方法:sudo chown -R root:wheel mysql ,然后重新启动
2.可能进程里已经存在mysql进程(之前安装过,但是电脑没有重启过)
解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9 进程号”杀死,然后重新启动mysqld!,要是没有办法杀死进程的话,那就重启电脑试试,我是重启电脑成功的!
还有其他可能的解决方法,但是我已经用了第二条解决了,所以接下的没有继续研究,有兴趣的可以查看这个链接:http://blog.rekfan.com/articles/186.html
相关的mysql文档链接:mysql的文档