1.下载mysql-5.7.9-winx64并解压到自定义路径
下载链接: https://pan.baidu.com/s/1_9ntmjr48MwBuPl2sDYeiA 密码: 3fyd
2.在解压后的文件夹中创建my-ini.ini文件,并拷入以下内容;
注意路径与自己设置的相符合;
####################配置文件开始###################
# For advice on how to change settings please see
# *** 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
[mysql]
default-character-set=utf8
[mysqld]
character-set-server=utf8
skip-grant-tables
port=3306
basedir ="D:/Program Files/mysql-5.7.9-winx64/"
datadir ="D:/Program Files/mysql-5.7.9-winx64/data/"
tmpdir ="D:/Program Files/mysql-5.7.9-winx64/data/"
socket ="D:/Program Files/mysql-5.7.9-winx64/data/mysql.sock"
log-error="D:/Program Files/mysql-5.7.9-winx64/data/mysql_error.log"
#server_id = 2
#skip-locking
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
innodb_data_home_dir="D:/Program Files/mysql-5.7.9-winx64/data/"
innodb_flush_log_at_trx_commit =1
innodb_log_buffer_size=128M
innodb_buffer_pool_size=128M
innodb_log_file_size=10M
innodb_thread_concurrency=16
innodb-autoextend-increment=1000
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
max_allowed_packet = 32M
explicit_defaults_for_timestamp=true
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
#1,不区分大小写
lower_case_table_names=1
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
####################配置文件结束###################
3.添加到系统环境变量
我的电脑--右键--高级系统设置--环境变量--选中系统变量中的Path--选择编辑--将mysql-5.7.9-winx64的bin文件夹路径(例如本人的是D:\Program Files\mysql-5.7.9-winx64\bin)添加进去--保存退出;
4.安装服务、初始化数据库、启动服务
以下命令使用管理员权限执行
#初始化数据库
C:\WINDOWS\system32>mysqld --initialize-insecure
#成功后目录下会生成data文件夹、
#安装服务
C:\WINDOWS\system32>mysqld -install
Service successfully installed.#成功的返回
#卸载服务使用 myaqld -remove
#启动服务
C:\WINDOWS\system32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
#停止服务
#C:\WINDOWS\system32>net stop mysql
#MySQL 服务正在停止.
#MySQL 服务已成功停止。
5.mysql配置修改
以下命令需要使用管理员权限并在MySQL服务启动成功后执行
#登录MySQL,密码默认为空
C:\WINDOWS\system32>mysql -uroot -p
Enter password: #直接回车
#登录成功显示数据
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.9 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#修改MySQL登录密码为root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
#返回数据 Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges; #刷新
#返回数据 Query OK, 0 rows affected (0.00 sec)
#允许所有主机使用root账号与root密码连接数据库
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
#退出MySQL
mysql> Quit;
网友评论