MySql在Win7(64位)下安装教程

来源:互联网 发布:网络热门微拍百度云 编辑:程序博客网 时间:2024/05/21 10:18

1、https://dev.mysql.com/downloads/mysql/ 下载免安装版zip文件,Windows (x86, 64-bit), ZIP Archive (mysql-5.7.19-winx64.zip) 318.5M

2、下载下来后解压到安装程序目录,比如我解压到了Program Files中

3、配置bin环境变量:

4、新建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.[client]default-character-set=utf8[mysqld]character_set_server=utf8# 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 = "E:\Program Files\mysql-5.7.19-winx64"datadir = "E:\Program Files\mysql-5.7.19-winx64\data"tmpdir = "E:\Program Files\mysql-5.7.19-winx64\data"socket = "E:\Program Files\mysql-5.7.19-winx64\data\mysql.sock"port = 3306log-error = "E:\Program Files\mysql-5.7.19-winx64\data\mysql_error.log"# server_id = .....max_connections = 100table_open_cache = 256query_cache_size = 1Mtmp_table_size = 32Mthread_cache_size = 8innodb_data_home_dir = "E:\Program Files\mysql-5.7.19-winx64\data\"innodb_flush_log_at_trx_commit = 1innodb_log_buffer_size = 128Minnodb_buffer_pool_size = 128Minnodb_log_file_size = 10Minnodb_thread_concurrency = 16innodb-autoextend-increment = 1000# 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 = 128Msort_buffer_size = 32Mread_rnd_buffer_size = 32Mmax_allowed_packet = 32Mexplicit_defaults_for_timestamp = truesql_mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

5、打开管理员命令行
mysqld -install mysql //添加

mysqld –initialize-insecure
以上代码将会生成一个没有密码的root用户,如果不加-insecure那么root用户的密码是随机生成到,到存在
log-error = “F:\mysql-5.7.12-winx64\data\mysql_error.log”

net start mysql

6、mysql密码重置
在配置文件中[mysqld]下方添加如下,意味着跳过验证,直接进入mysql
skip-grant-tables

7、update mysql.user set authentication_string=password(‘123456’) where user=’root’ and Host = ‘localhost’;
执行以上语句后,再把上面那句跳过验证的命令去掉就好。

use mysql;set password = password("admin123")

8、 MySQL安装或重装后出现无法启动MySQL服务错误:发生系统错误2 系统找不到指定的文件
需要去注册表中LOCAL_MACHINE SYSTEM CYRRENTCONTROLSET SERVICES MYSQL中的ImagePath值改为以下这样
“E:\Program Files\mysql-5.7.19-winx64\bin\mysqld” mysql

9、执行show databases提示:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement befo
re executing this statement.
使用这个 set password = password(“admin123”)