下载路径: https://dev.mysql.com/downloads/file/?id=480490 (也可下载免安装版)
net start mysql 启动服务
情况1
[MySql]默认密码的查找与修改
在安装成功后,怎么找到mysql的默认密码,折腾很长时间,最后发现在安装的过程中,产生了一个默认的随机密码。
密码
在mysql安装目录生成的data文件下,查找xxx.err的文件如图:
可以看到临时密码:<a5F34))PqMb,使用cmd命令行工具,用临时密码登录,进行修改密码
情况2
解决方法如下:
1. 通过任务管理器结束mysql进程
2. 命令行进入%MYSQL_HOME%\bin目录,输入mysqld --skip-grant-tables(跳过权限检查启动mysql)
3. 打开一个新cmd窗口,输入:mysql,即可登录数据库
4. 输入update mysql.user set authentication_string=password('123') where user='root' and Host ='localhost'; (更新密码)
5. 再次结束所有sql进程,重新启动(net start mysql)并登陆
命令:mysql -u root -p
set password for root@localhost = password('123');
1 修改配置文件basedir和datadir配置。
# 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]
# 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-5.7.17-winx64 #数据库安装路径 关键两行
datadir =C:\Program Files\MySql\mysql-5.7.17-winx64\data # 日志放在数据库同一路径,便于查询
# port = .....
# server_id = .....
# 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
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
2 添加环境变量
我的电脑->属性->环境变量-PATH
C:\Program Files\MySql\mysql-5.7.17-winx64\bin;
管理员身份运行CMD,并进入bin目录。安装mysql。命令:mysqld -install
最后启动数据库,不同系统版本不一,本文适合win8及mysql 5.7.26