1. 下载安装包
2. 解压安装包到目标位置:C:\Program Files\MySQL\mysql-5.7.29
3. 配置环境变量
path后面添加 ,C:\Program Files\MySQL\mysql-5.7.29\bin\
4. 编辑配置文件
在安装目录下创建my.ini
[mysqld] port=3306 character_set_server=utf8 basedir=C:\Program Files\MySQL\mysql-5.7.29 datadir=C:\Program Files\MySQL\mysql-5.7.29\data server-id=1 sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION lower_case_table_names=1 innodb_file_per_table = 1 log_timestamps=SYSTEM log-error = error.log slow_query_log = 1 slow_query_log_file = slow.log long_query_time = 5 log-bin = binlog binlog_format = row expire_logs_days = 15 log_bin_trust_function_creators = 1 secure-file-priv=C:\Program Files\MySQL\mysql-5.7.29\Uploads max_allowed_packet = 32M binlog_cache_size = 4M sort_buffer_size = 2M read_buffer_size = 4M join_buffer_size = 4M tmp_table_size = 96M max_heap_table_size = 96M lower_case_table_names=1 innodb_file_per_table = 1 [client] default-character-set=utf8
5. 数据库初始化
cmd命令行执行:mysqld --initialize-insecure
6. 注册mysql服务
cmd命令行执行:mysqld –-install mysql
检查服务已存在:
7. mysql服务启动与关闭
net start mysql net stop mysql
启动服务报错:
解决办法:
卸载mysql服务: mysqld --remove mysql
重新安装mysql服务:
注意注册服务时,命令需要进入mysql安装目录下的bin目录运行!
8. 修改root口令
默认口令可以从error.log中查找,此版本默认口令为空。
alter user ‘root‘@‘localhost‘ identified by ‘root‘; flush privileges; 或者: use mysql; update user set authentication_string=password("root") where user="root"; flush privileges;
9. 配置root远程登录
use mysql; grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘root‘ with grant option; flush privileges;
远程登陆测试: