参考
下载mysq5.7的安装包
解压到某个指定为文件夹,解压完之后在其根目录底下新建一个my.ini(也可以直接复制原来默认的my-default.ini),然后添加内容,注意,里面的中文在实际中要去掉,my.ini是在mysql目录的底下
[mysqld]#绑定IPv4和3306端口bind-address=0.0.0.0 port=3306 #设置mysql的安装目录 basedir=E:\mysql #设置mysql数据库的数据的存放目录 datadir=E:\mysql\data #允许最大连接数 max_connections=200 #设置字符集为utf loose-default-character-set=utf8 character-set-server=utf8 [client] #设置客户端字符集 loose-default-character-set=utf8 [WinMySQLadmin] Server=E:\mysql\bin\mysqld.exe
在PATH里面添加环境变量,变量内容就是bin的地址 如: E:\mysql\bin
管理员的身份进入命令行模式(在这个C:\Windows\System32目录底下) 运行命令:'''mysqld --initialize''' 运行命令 mysqld -install
安装
mysqld --initialize
初始化数据字典运行命令net start mysql
启动服务 注意:安装成功后就要启动服务了,继续在cmd中输入:net start mysql(如图),服务启动成功! 此时很多人会出现错误,请看注意: 注意:这个时候经常会出现错误2和错误1067。 如果出现“错误2 系统找不到文件”,检查一下是否修改过配置文件或者是否进入在bin目录下操作,如果配置文件修改正确并且进入了bin文件夹,需要先删除mysql(输入 mysqld -remove)再重新安装(输入 mysqld -install); 如果出现错误1067,那就是配置文件修改错误,确认一下配置文件是否正确。
运行命令 mysql -u root -p 然后输入临时密码,这个临时密码是在data文件夹下面的.err结尾的文件里面,有个 A temporary password is generated for root@localhost
日志
然后更改密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
mysql卸载方法
停止服务:net start mysql
删除data文件卸载:mysqld -remove
# 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.# basedir = .....# datadir = .....# 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 [mysqld]lower_case_table_names=0#绑定IPv4和3306端口bind-address=0.0.0.0port=3306#设置mysql的安装目录basedir=D:\DevelopSoftware\mysql#设置mysql数据库的数据的存放目录datadir=D:\DevelopSoftware\mysql\data#允许最大连接数max_connections=200#设置字符集为utfloose-default-character-set=utf8character-set-server=utf8[client]#设置客户端字符集loose-default-character-set=utf8[WinMySQLadmin]Server=D:\DevelopSoftware\mysql\bin\mysqld.exelower_case_table_names=0#客户端导入导出数据用到secure_file_priv=D:\DevelopSoftware\mysql