1)官网下载mysql5.7.17解压
my-default.ini文件命名为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.
[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.
character-set-server=utf8
collation-server=utf8_general_ci
basedir = "D:\mysql-5.7.12"
datadir = "D:\mysql-5.7.12\data"
port = 3306
# 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
[mysql]
default_character_set=utf8
[mysql.server]
default_character_set = utf8
[mysqld_safe]
default_character_set = utf8
[client]
default_character_set = utf8
-----------------------------------------------------------------------------------------------
2)安装服务:
mysqld -install mysql
net start mysql
发现错误1067 Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
直接用命令初始化:
指定配置文件:mysqld --install mysql --defaults-file="D:\mysql-5.7.12\my.ini
初始化:mysqld --defaults-file=D:\mysql-5.7.12\my.ini --initialize
3)修改密码:
mysqld --skip-grant-tables 启动mysql
打开新的cmd:mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD('root') WHERE user='root';
4)远程登陆mysql例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
OK