1.下载mysql
https://dev.mysql.com/downloads/mysql/5.6.html#downloads
根据具体情况,选择适合mysql版本
2.然后解压mysql压缩包
解压的文件为mysql-5.6.44-winx64
然后拷贝到指定的目录下即可
3.拷贝my-default.ini为my.ini
然后修改配置文件
# 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] ##跳过密码认证,进行修改密码 #skip-grant-tables # 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 = ..... # datadir = ..... # port = ..... # server_id = ..... # 设置mysql的安装目录 basedir = C:/setup/mysql-5.6.44-winx64 # 设置mysql数据库的数据的存放目录 datadir = C:/setup/mysql-5.6.44-winx64/data port = 3306 # server_id = ..... # 允许最大连接数 max_connections = 200 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB # 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
4.在C:\Windows\System32目录下找cmd.exe鼠标右击以管理员身份打开
然后切换到mysql的bin目录下
5.安装mysql
mysqld.exe install
6.启动mysql
net start mysql #启动
net stop mysql #停止
出现的报错
检查my.ini配置文件,是否有语法错误还是参数错误;当前的这种情况是配置datadir的路径有误:之前是datadir = C:/setup/mysql-5.6.44-winx64/data/mysqldata;改为datadir = C:/setup/mysql-5.6.44-winx64/data就正常启动了
7.首次修改密码
mysql -u root #默认是没有密码的
use mysql;
update user set password=PASSWORD(“123456”)where user=“root”;
flush privileges
8.添加系统环境变量路径
在系统环境变量path里面添加mysql的路径 #可选
找到path变量,使用;分割添加mysql的路径即可C:\setup\mysql-5.6.44-winx64\bin