Windows 中 安装zip归档版 MySQL

环境:

    操作系统: Windows7 sp1 旗舰版 64位

    MySQL包:mysql-5.5.62-winx64.zip

1. 解压 MySQL zip安装包 到 需要的位置,并将解压出来的文件夹重命名为 mysql

2.创建 MySQL 配置文件,其基本内容为 MySQL 的安装目录 和 MySQL 的 data 数据
库存放目录,例如:

[mysqld]
# set basedir to your installation path
basedir=E:/mysql
# set datadir to the location of your data directory
datadir=E:/mydata/data

这是基本的内容,更多配置项请参考:https://dev.mysql.com/doc/refman/5.6/en/server-option-variable-reference.html

3.首次启动 MySQL

    首次启动建议 通过 命令行 启动,这样便于查看消息解决问题(注意路径替换为你的)。

C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld" --console

    如果服务器 支持 InnoDB ,在启动时则会看到类似如下信息:

扫描二维码关注公众号,回复: 13586981 查看本文章
InnoDB: The first specified datafile c:\ibdata\ibdata1 did not exist:
InnoDB: a new database to be created!
InnoDB: Setting file c:\ibdata\ibdata1 size to 209715200
InnoDB: Database physically writes the file full: wait...
InnoDB: Log file c:\iblogs\ib_logfile0 did not exist: new to be created
InnoDB: Setting log file c:\iblogs\ib_logfile0 size to 31457280
InnoDB: Log file c:\iblogs\ib_logfile1 did not exist: new to be created
InnoDB: Setting log file c:\iblogs\ib_logfile1 size to 31457280
InnoDB: Log file c:\iblogs\ib_logfile2 did not exist: new to be created
InnoDB: Setting log file c:\iblogs\ib_logfile2 size to 31457280
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: creating foreign key constraint system tables
InnoDB: foreign key constraint system tables created
011024 10:58:25  InnoDB: Started
	

    当,看到如下信息时,则表明,服务器启动成功可以连接:

mysqld: ready for connections
Version: '5.6.51'  socket: ''  port: 3306

4.从 Windows 命令行中 启动 MySQL(注意路径替换为你的)

C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld"

5.从 Windows 命令行中 停止 MySQL(注意路径替换为你的)

C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqladmin" -u root shutdown

6.开机自启动。将 MySQL 安装为系统服务(注意路径替换为你的),安装前先使用上述命令停止MySQL。

C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld" --install

7.还可以 添加 --defaults-file 来指定 MySQL的配置文件 my.cnf,例如:

C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld" --install --defaults-file=C:\MySQL\my.cnf 

详情请参考:https://dev.mysql.com/doc/refman/5.6/en/windows-start-service.html


再将 MySQL 加入系统环境变量

上面操作都完成后,MySQL 的 root 用户默认是没有密码的,做需要手工设置密码,具体操作如下:

先在 windows 命令行中,使用 mysql -u root -p 命令登录MySQL。
    
    然后再使用如下命令设置root用的密码

       首先,选择 mysql 这个数据库

mysql> use mysql;
Database changed

        然后使用如下命令设置 root 用户 的 密码

mysql> UPDATE user SET Password = PASSWORD('123456') WHERE user = 'root';

        然后刷新权限

mysql> FLUSH PRIVILEGES;

    以上两条 sql 语句执行完毕后,如果都看到了 Query OK 字样则说明操作成功。

至此,基本的安装配置就完成了。

猜你喜欢

转载自blog.csdn.net/weixin_45956258/article/details/112980298