background
I don't like the installation version of mysql very much. I prefer the decompressed version. The download from the official website is relatively slow. The download speed of the following address is ok.
Download address: http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.35-winx64.zip
installation steps
After downloading, unzip it and put it in the directory you are used to.
D:\SoftwareDev\mysql-5.6.35-winx64
Configure environment variables
Add a MYSQL_HOME variable, and then add %MYSQL_HOME%\bin to the original Path variable
MYSQL_HOME=D:\SoftwareDev\mysql-5.6.35-winx64
Path=....%MYSQL_HOME%\bin
Configuration Modify the basedir and datadir of the my-default.ini configuration file
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/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. basedir = D:\SoftwareDev\mysql-5.6.35-winx64 datadir = D:\SoftwareDev\mysql-5.6.35-winx64\data # port = ..... # 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
Install windows service in administrator mode
- How to open admin command line in win 10
right click start menu
- How to open admin command line in win 7
Left click on the start menu
Run the following command to install the WINDOWS service named MySQL
mysqld install MySQL
服务安装成功提示Service successfully installed.
启动MySQL服务
- 命令行启动方式
net start MySQL
- 在服务管理工具中启动
运行services.msc 找到MySQL,右键启动
注意:如果启动发生错误,请详细查看错误日志,在D:\SoftwareDev\mysql-5.6.35-winx64\data\${计算机名}.err
启修改MySQL root用户密码
默认安装完,root密码为空
用mysql命令登录,这里root用户没有密码的,直接回车就好了
我列一下上面每个步骤:
- 切换到mysql这个数据库
use mysql;
- 更新root 用户密码
update user set password=password('123456') where user='root';
- 刷新权限
flush privileges
搞定!
这里再提一点,创建数据库用户,及指定该用户可以访问的数据库的语句
当然首先你得创建一个数据库
create database mydb;
grant all privileges on mydb.* to 'jaychang'@'ip' identified by '123456';
解释下,这里的jaychang为数据库用户名,ip为访问来源ip,这里可以指定ip网段,比如192.168.56.%,表示只有IP地址192.168.56开始的才能访问,也可以是域名。可以是localhost,如果是localhost表示只能再本机上访问。identified by 后面的即是jaychang用户的密码。