免安装mysql-5.7.17-winx64配置详解

转自Tracy的笔记:
1.解压缩
2.添加环境变量    %MYSQL_HOME% set path =   %MYSQL_HOME%\bin
3添加配置文件:

[mysql] 

default-character-set=utf8

[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 = D:\mysql-5.7.17-winx64
 datadir = D:\mysql-5.7.17-winx64\data
 port = 3306
explicit_defaults_for_timestamp = TRUE 
 default-storage-engine=INNODB
 character-set-server=utf8
 max_allowed_packet=50M
 server_id = 1

general-log=0 
general_log_file="mysql_general.log" 
slow-query-log=1 
slow_query_log_file="mysql_slow_query.log" 
long_query_time=10 
log-error="mysql_error_log.err" 

max_connections=1024 
query_cache_size=128M 
key_buffer_size=128M 
innodb_flush_log_at_trx_commit=1 
innodb_thread_concurrency=128 
innodb_autoextend_increment=128M 
tmp_table_size=128M 

# 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 = 2G 

# 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_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

4初始化数据库
     以管理员自身份打开CMD执行以下命令(注意必须以管理员身份打开,否则报错)
mysqld --initialize --user=mysql --console
在控制台消息尾部会出现随机生成的初始密码,记下来(因为有特殊字符,很容易记错,最好把整个消息保存在记事本里)

5将MySQL添加到系统服务
     以管理员自身份打开CMD执行以下命令(注意必须以管理员身份打开,否则报错)
mysqld --install MySQL
net start MySQL

6启动MySQL并修改密码
     在CMD控制台里执行命令 mysql -u root -p
回车执行后,输入刚才记录的随机密码
执行成功后,控制台显示 mysql>,则表示进入mysql
输入命令set password for root@localhost = password('123'); (注意分号)

遇到的问题:
查看mysql_error_log.err日志文件是解决基本上所有错误的关键
innodb_buffer_pool_size = 2G 
设置缓存池大小要根据所在系统的内存大小来配置,报错在写在mysql_error_log.err文件中

MYSQL系统服务启动不了的问题:解决方法通过注册表中Service文件夹中查看服务
imagePath变量的路径是否是mysqld.exe所在路径

授权远程计算机都可以连接到mysql服务器。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;

































你可能感兴趣的:(琐事)