在学习一门知识的时候,开始总会走些弯路。如果把一路所见所闻都记录下来,结果一定会是绚丽的风景!!!
下载安装文件
选择自已所要安装的版本,我的是 MySql5.7.10.install.win.64
文件解压到安装目录
D:\mysql\mysqldatabase\
配置环境变量 MYSQL_HOME = D:\mysql\mysqldatabase
Path = %MYSQL_HOME%\bin
配置 my.ini 文件
见附录 A001 。
在zip包中已经不含data目录,需要自已创建一个空目录,而且必须为空。
******具体的命令行操作,dos窗口要以管理员身份运行******
初始化 mysqld --initialize or --initialize-insecure
a) mysqld --initialize 会显示一个随机密码,使用此密码登陆.但是我没有找到随机密码在哪里? -_-
b) mysqld --initialize-insecure 可以直接进行mysql -uroot登陆. 密码是空。
如果不行,可以使用mysql -uroot --skip-password登陆,成功后修改密码。
但是我没有用 mysql -uroot --skip-password
添加服务 %MYSQL_HOME%/bin 目录下运行 mysqld 命令
mysqld install MysqlSvc --defaults-file="D:\mysql\mysqldatabase\my.ini"
移除服务命令为:mysqld remove
win运行中输入 services.msc 可以查看添加的服务。
启动服务:net start MysqlSvc
关闭服务:net stop MysqlSvc
启动服务 net start MysqlSvc
-> D:\mysql-5.7.9-winx64\bin>net start MysqlSvc
-> MySQL 服务正在启动 .
-> MySQL 服务已经启动成功。
修改密码 修改密码默认密码步骤: (mysqld --initialize-insecure 初始化)
-> mysql -uroot
mysql>
mysql>update user set authentication_string=password('password')
where user='root'
mysql>quit;
重启mysql服务, --- 新mysql5.7 没有authentication_string字段。---
附录:
A001**
# 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]
default-character-set=utf8
### 注意: [client] 与 [mysqld] 位置与配置参数混乱问题
### 会出错: variable 无效参数
[mysqld]
#跳过密码
#skip-grant-tables
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
port=3306
basedir ="D:\mysql\mysqldatabase/"
datadir ="D:\mysql\mysqldatabase/data/"
tmpdir ="D:\mysql\mysqldatabase/data/"
socket ="D:\mysql\mysqldatabase/data/mysql.sock"
log-error="D:\mysql\mysqldatabase/data/mysql_error.log"
#server_id = 2
#skip-locking
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
innodb_data_home_dir="D:\mysql\mysqldatabase/data/"
innodb_flush_log_at_trx_commit =1
innodb_log_buffer_size=128M
innodb_buffer_pool_size=128M
innodb_log_file_size=10M
innodb_thread_concurrency=16
innodb-autoextend-increment=1000
max_allowed_packet = 32M
explicit_defaults_for_timestamp=true
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
####################配置文件结束###################