windows下mysql5.7安装及配置

装完msi后,复制my-default.ini文件,黏贴为my.ini文件,内容修改如下:

# 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.

[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 = "C:/Program Files/MySQL/MySQL Server 5.7"
datadir = "C:/Program Files/MySQL/MySQL Server 5.7/data"
tmpdir="C:/Program Files/MySQL/MySQL Server 5.7/temp"
bind-address = 127.0.0.1
port =3306
server_id = 1

# 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
#socket = /tmp/mysql.sock
#max_connections=50
#default-storage-engine=MYISAM
#skip-locking
#set-variable = key_buffer=16K
##set-variable = max_allowed_packet=1M
#set-variable = thread_stack=64K
#set-variable = table_cache=4
#set-variable = sort_buffer=64K
#set-variable = net_buffer_length=2K
#set-variable = max_connections=32000
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

然后在cmd中进入bin目录,输入mysqld  --initialize
这个命令是为了初始化mysql,生成data目录

然后提示用--explicit_defaults_for_timestamp选项,于是更改成这个选项

然后运行mysqld -nt-install mysql

提示成功,然后去系统环境变量设置,将bin目录添加到path

5.7以上版本的 MySQL 默认使用了支持事物的 INNODB 引擎,打开 my.ini 文件,在 MySQL 的安装文件夹, 如 c:program filesMySQL 中,看到:

把设置改为

default-storage-engine=MYISAM

然后运行net start mysql

仍然失败,于是去C:\Program Files\MySQL\MySQL Server 5.7\data目录查看err后缀的错误日志,以下是针对性的解决办法

Mysql 错误1067 Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 解决办法

就是mysql数据库有问题,具体来说就是user表有问题。

网上解决方案多是linux下的,初始化数据库就ok,即:mysql_install_db --user=mysql

Windows下的这招不能用,

到data\mysql目录下一看,找不到user.frm,user.MYD,user.MYI三个文件,即user表被删了。。

于是从下载的mysql.zip中把三个文件拷过去就行,

当然原来的用户名密码全部重置了,看来这也是个破解mysql密码的方法…

日志继续报错:[Note] Plugin 'FEDERATED' is disabled.

解决办法:删除MySQL目录下的ib_logfile0和ib_logfile1两个文件,去某路径建立缓存文件夹,temp目录

然后在my.ini中添加:

[mysqld]
#自己指定的临时文件目录
tmpdir="E:/Program Files/MySQL/MySQL Server 5.1/Temp/"

然后把c盘windows/system32/etc目录下的host文件添加一行127.0.0.1 localhost

全部配置完毕后输入net start mysql提示启动成后

输入net start 可以看到有mysql

然后我输入mysql进入时报错:ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password:NO)

原来配置文件少加一行,加了skip-grant-tables就好了

上一篇:Oracle PL/SQL中的循环处理(sql for循环)


下一篇:linux SSH免密码登录远程服务器