步骤如下:
1. 下载mysql 5.7 版本,我本机mysql版本是mysql-5.7.12-winx64 , 操作系统window7 64
2. 在mysql的目录下, 添加my.ini 文件。
文件内容:
[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:\\software\\mysql-5.7.12-winx64
datadir = D:\\software\\mysql-5.7.12-winx64\\data
port = 3306
max_connections=200
bind-address=127.0.0.1
character-set-server=utf8
# 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
注意: data的路径最好建立在mysql的路径下。
3. 以管理员启动cmd ,并进入到mysql目录下。
4. 安装mysql服务 然后在 bin 目录下面输入 mysqld --install
5 初始化mysql ,mysqld --initialize --console
这是初始化数据库, 然后你可以在初始化的最后面看到有一个 root@localhost: 后面有一连串的字母数字符号, 这是 MySQL 为你自动生成的随机密码. 要记下来, 一会我们登陆 MySQL 数据库的时候要用.
6. 启动 MySQL 服务, 启动了你才能用 MySQL 数据库.
有两种方式可以启动 MySQL:
方法一: 用命令启动
net start mysql
7. : 修改MySQL默认密码
启动了之后, 我们登陆 MySQL 数据库, 输入命令
mysql -uroot -p
回车, 要求你输入密码, 这时, 把刚才 MySQL 随机生成的密码输入, 然后回车, 就登陆进去了.
登陆进去之后, 直接输入:
SET PASSWORD = PASSWORD('你的新密码');