背景
5.7版本的mysql离线版安装有很多坑,在此一一记载。
下载
下载页面下载64位zip包,
解压
解压文件。
初始化配置
在文件目录下,找到my-default.ini
文件,复制并重命名my.ini
,然后指定data目录。
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
port=3306
[mysql]
default-character-set=utf8
[mysqld]
port=3306
basedir="D:/DevelopTools/mysql5_7_14"
datadir="D:/DevelopTools/mysql5_7_14/data"
character-set-server=utf8
default-storage-engine=INNODB
安装mysql服务
需要在管理员权限下执行cmd。
在bin目录下,
D:\DevelopTools\mysql5_7_14\bin>mysqld --install
Service successfully installed.
启动mysql
在bin目录下,执行
D:\DevelopTools\mysql5_7_14\bin>net start mysql
报错
D:\DevelopTools\mysql5_7_14\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务无法启动。
服务没有报告任何错误。
请键入 NET HELPMSG 3534 以获得更多的帮助。
查看mysql日志
在data目录下,查看*.err文件。
2016-08-23T13:20:42.303713Z 0 [Note] Plugin 'FEDERATED' is disabled.
MySQL: Table 'mysql.plugin' doesn't exist
2016-08-23T13:20:42.305713Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-08-23T13:20:42.308713Z 0 [Note] Salting uuid generator variables, current_pid: 3656, server_start_time: 1471958439, bytes_sent: 0,
2016-08-23T13:20:42.337715Z 0 [Note] Generated uuid: '644d3f84-6934-11e6-9f6d-507b9d0180aa', server_start_time: 1471962095, bytes_sent: 109367744
2016-08-23T13:20:42.338715Z 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: 644d3f84-6934-11e6-9f6d-507b9d0180aa.
2016-08-23T13:20:42.365717Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-08-23T13:20:42.368717Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2016-08-23T13:20:42.369717Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-08-23T13:20:42.372717Z 0 [Note] IPv6 is available.
2016-08-23T13:20:42.373717Z 0 [Note] - '::' resolves to '::';
2016-08-23T13:20:42.374717Z 0 [Note] Server socket created on IP: '::'.
2016-08-23T13:20:42.380718Z 0 [Warning] Failed to open optimizer cost constant tables
2016-08-23T13:20:42.382718Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
解决方案
http://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
清空data目录内容
首先需要情况data目录下内容,否则会报错
D:\DevelopTools\mysql5_7_14\bin>mysqld --initialize
2016-08-23T13:27:23.129639Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2016-08-23T13:27:23.132639Z 0 [ERROR] --initialize specified but the data direct
ory has files in it. Aborting.
2016-08-23T13:27:23.132639Z 0 [ERROR] Aborting
执行初始化命令
D:\DevelopTools\mysql5_7_14\bin>mysqld --initialize
启动服务
D:\DevelopTools\mysql5_7_14\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
卸载myql服务
在mysql的bin目录下:
mysqld --remove
mysql登录
跳过密码
首次登录时,设置跳过密码,可以进入数据库修改密码信息。
在my.ini
中
# 跳过密码验证
skip-grant-tables
修改密码
mysql> use mysql
Database changed
mysql> update user set authentication_string=password("root") where user="root";
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
重启服务后登录。
D:\DevelopTools\mysql5_7_14\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
D:\DevelopTools\mysql5_7_14\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
网友评论