MySQL 5.7.19 忘记密码 重置密码 配置文件my.ini示例 服务启动后停止 log配置

【参考】java 项目 存入mysql后 变问号 MySql 5.6 (X64) 解压版 1067错误与编码问题的解决方案

一、my.ini 的mysqld下添加

  skip-grant-tables

二、重启mysql服务

  net start mysqld

三、打开cmd

  cd C:\Program Files\MySQL\MySQL Server 5.7\bin
  mysql
  use mysql
  设置新密码
  update mysql.user set authentication_string=password('mima****') where user='root' and Host='localhost';

  UPDATE user SET authentication_string=password('1234') where user='root' and Host='localhost';

  alter user 'root'@'localhost' identified by '123';  改密码?

  flush privileges;

  5.7以前版本可用UPDATE user SET Password=PASSWORD('newpassword') where USER='root';更新密码

四、恢复my.ini  重启mysql服务

五、本地计算机上的MySQL服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止

    1. 解压mySQL绿色版zip包 -> 配置环境变量
    2. 用管理员身份运行cmd,mysqld –initialize-insecure,data文件夹会自动生成,注意单词不要拼错 -> 运行 mysqld –install 安装Windows服务

    3. my.ini 配置文件放在MYSQL_HOME目录下,不要配置 basedir,datadir,不要配置 basedir,datadir,不要配置 basedir,datadir!!!【参照】 Mysql-5.7.19-winx64服务无法启动解决方案

 my.ini 精简示例 (5.7.19 可放在 MYSQL_HOME 目录下,MySQL能启动不报错)

#代码开始
[client]
port=3306
default-character-set=utf8

[mysqld]
port=3306
character_set_server=utf8

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

innodb_buffer_pool_size=2048M
#innodb_buffer_pool_instances=1
innodb_log_buffer_size=4M
innodb_log_file_size=256M
#innodb_additional_mem_pool_size=4M

# 允许最大连接数
max_connections=1024
#服务器在关闭它前在一个交互连接上等待行动的秒数
wait_timeout = 7200
#服务器有几个CPU就设置为几,建议用默认设置,一般为8.
innodb_thread_concurrency = 8

key_buffer_size=128M
tmp_table_size=128M
read_buffer_size=4M
read_rnd_buffer_size=16M
sort_buffer_size=32M


[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8

 my.ini 常规示例(log配置) (5.7.19)

#配置开始
[client]
port=3306
default-character-set=utf8

[mysqld]
port=3306
character_set_server=utf8
#跳过登陆验证
#skip-grant-tables
#禁止反向解析
#skip-name-resolve

#各种日志(查询、错误、慢查询)配置:
#log_bin=..\log\mysql-bin.log
log_error=..\log\mysql.err
long_query_time=1
slow_query_log=ON
slow_query_log_file=..\log\mysql-slow.log
general_log=ON
general_log_file=..\log\log-mysql.log

# 允许最大连接数
max_connections=1024
#服务器在关闭它前在一个交互连接上等待行动的秒数
wait_timeout = 7200
#服务器有几个CPU就设置为几,建议用默认设置,一般为8.
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=128M
innodb_buffer_pool_size=2048M
innodb_log_file_size=256M
innodb_thread_concurrency=16
innodb-autoextend-increment=1000
#innodb_additional_mem_pool_size=4M

table_open_cache=256
query_cache_size=1M
tmp_table_size=128M
thread_cache_size=8
key_buffer_size=128M
read_buffer_size=4M
join_buffer_size=128M
sort_buffer_size=32M
read_rnd_buffer_size=32M
max_allowed_packet=32M
explicit_defaults_for_timestamp=true


sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB


[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8

 

posted @ 2018-01-30 16:26  Rocken.li  阅读(593)  评论(0编辑  收藏  举报