Windows10安装MySQL5.7.18解压缩版
2018-06-17 23:37:40来源:未知 阅读 ()
Windows10安装MySQL5.7.18解压缩版
因为是边安装边写,而且MySQL5.7版本及以后安装都挺蛋疼的,所以可能有很多玄学错误导致安装无法成功。总之请多指教。
安装环境以及软件版本
Windows:Windows10 x64 家庭中文版
MySQL:Microsoft Windows x86,64-bit zip archive
安装过程
1.下载安装文件
简单来说就是:登陆官网(https://www.mysql.com/)=>Downloads=>Community=>MySQL Community Server=>Microsoft Windows & Windows(x86,64-bit)=>ZIP Archive & Download=>No thanks, just start my download.
之后下载过程就会开始。
2.开始安装
按照官方的文档:https://dev.mysql.com/doc/refman/5.7/en/windows-install-archive.html
2.3.5 Installing MySQL on Microsoft Windows Using a noinstall Zip Archive
- 2.3.5.1 Extracting the Install Archive
- 2.3.5.2 Creating an Option File
- 2.3.5.3 Selecting a MySQL Server Type
- 2.3.5.4 Initializing the Data Directory
- 2.3.5.5 Starting the Server for the First Time
- 2.3.5.6 Starting MySQL from the Windows Command Line
- 2.3.5.7 Customizing the PATH for MySQL Tools
- 2.3.5.8 Starting MySQL as a Windows Service
- 2.3.5.9 Testing The MySQL Installation
Users who are installing from the
noinstall
package can use the instructions in this section to manually install MySQL. The process for installing MySQL from a Zip archive is as follows:
Extract the main archive to the desired install directory
Optional: also extract the debug-test archive if you plan to execute the MySQL benchmark and test suite
Create an option file
Choose a MySQL server type
Initialize MySQL
Start the MySQL server
Secure the default user accounts
This process is described in the sections that follow.
可知步骤大概是:
- 解压文件到安装目录
- 创建配置文件
- 选择安装类型
- 初始化MySQL
- 启动MySQL服务
- 确保用户账户安全
这几个步骤。看起来挺简单的,但考虑到MySQL的安装有多坑,我还是挺慌的。
那么,我也按文档一步步安装吧。
1.创建一个安装目录并将下载好的安装文件解压到目录中
如图,然后是解压。
对了,文档上有几个要点要注意下:
2.3.5.1 Extracting the Install Archive
To install MySQL manually, do the following:
If you are upgrading from a previous version please refer to Section 2.3.8, “Upgrading MySQL on Windows”, before beginning the upgrade process.
Make sure that you are logged in as a user with administrator privileges.
Choose an installation location. Traditionally, the MySQL server is installed in
C:\mysql
. The MySQL Installation Wizard installs MySQL underC:\Program Files\MySQL
. If you do not install MySQL atC:\mysql
, you must specify the path to the install directory during startup or in an option file. See Section 2.3.5.2, “Creating an Option File”.NoteThe MySQL Installer installs MySQL under
C:\Program Files\MySQL
.Extract the install archive to the chosen installation location using your preferred Zip archive tool. Some tools may extract the archive to a folder within your chosen installation location. If this occurs, you can move the contents of the subfolder into the chosen installation location.
注意第2条和第4条,有两点需要注意:
- 当前登陆用户必须拥有管理员权限
- 有些压缩软件会在解压缩时把结果放入一个目录中方便管理,如果发生这种情况,请将解压缩的内容移动到上一级文件夹中
关于第1条,我也不知道要怎么确认,走一步算一步吧。而第2条,现在的压缩工具都是这样的啊。总之,多谢相告。
如图,解压的结果就是这样了。考虑下刚才文档里说的,姑且把里面的内容移到上一层目录吧,如图:
那么开始下一步吧。
2.创建配置文件
根据文档内容:
When the MySQL server starts on Windows, it looks for option files in several locations, such as the Windows directory,
C:\
, and the MySQL installation directory (for the full list of locations, see Section 5.2.6, “Using Option Files”). The Windows directory typically is named something likeC:\WINDOWS
. You can determine its exact location from the value of theWINDIR
environment variable using the following command:C:\>echo %WINDIR%
MySQL looks for options in each location first in the
my.ini
file, and then in themy.cnf
file. However, to avoid confusion, it is best if you use only one file. If your PC uses a boot loader whereC:
is not the boot drive, your only option is to use themy.ini
file. Whichever option file you use, it must be a plain text file.
貌似,配置文件my.ini必须放在系统目录中。如果不知道这个目录位置,可以用 echo %WINDIR% 来获取。如图:
可以看到,C:\Windows正是这个Windows Directory。但是,这个目录里面的文件多且杂,而且大多对于系统很重要,且这个文件是有访问控制的,我担心程序会因为权限的原因启动失败。考虑这些原因,还是不要把配置文件放入系统目录为好。
那么,可以放在其它路径么?让我翻一下文档。
On Windows, MySQL programs read startup options from the files shown in the following table, in the specified order (top files are read first, files read later take precedence).
Table 5.1 Option Files Read on Windows Systems
File Name Purpose ,
%PROGRAMDATA%
\MySQL\MySQL Server 5.7\my.ini
%PROGRAMDATA%
\MySQL\MySQL Server 5.7\my.cnfGlobal options ,
%WINDIR%
\my.ini
%WINDIR%
\my.cnfGlobal options C:\my.ini
,C:\my.cnf
Global options ,
BASEDIR
\my.ini
BASEDIR
\my.cnfGlobal options defaults-extra-file
The file specified with --defaults-extra-file
, if any
%APPDATA%
\MySQL\.mylogin.cnfLogin path options (clients only)
In the preceding table,
%PROGRAMDATA%
represents the file system directory that contains application data for all users on the host. This path defaults toC:\ProgramData
on Microsoft Windows Vista and greater, andC:\Documents and Settings\All Users\Application Data
on older versions of Microsoft Windows.
%WINDIR%
represents the location of your Windows directory. This is commonlyC:\WINDOWS
. Use the following command to determine its exact location from the value of theWINDIR
environment variable:C:\>echo %WINDIR%
%APPDATA%
represents the value of the Windows application data directory. Use the following command to determine its exact location from the value of theAPPDATA
environment variable:C:\>echo %APPDATA%
BASEDIR
represents the MySQL base installation directory. When MySQL 5.7 has been installed using MySQL Installer, this is typicallyC:\
wherePROGRAMDIR
\MySQL\MySQL 5.7 ServerPROGRAMDIR
represents the programs directory (usuallyProgram Files
on English-language versions of Windows), See Section 2.3.3, “MySQL Installer for Windows”.
在文档5.2.6 Using Option Files中,有配置文件的读取顺序。看不懂第一条是什么鬼,不过可以看出第4条是指安装目录。虽然优先级不高,但是应该其它目录没有同名的文件就能生效。
那么在安装目录下建立配置文件:
注意文件的编码格式最好是utf-8无BOM格式。内容如下:
[mysqld] basedir=D:\\webserver\\mysql-5.7.18 datadir=D:\\webserver\\mysql-5.7.18\\data port=3306
只是启动的话这样的内容应该是足够的。
3.选择MySQL服务类型
其实我也不懂这个MySQL服务类型指的是什么。存粹是根据 2.3.5.3 Selecting a MySQL Server Type 文档标题直译的。总之一步步来吧。
看过文档,貌似这一步只是科普,什么都不用做。那么我们一头雾水开始下一步吧。
4.初始化数据库目录文件
这一步十分重要。相信有Linux或Unix编译安装MySQL经历的都应该有所了解。总的来说,这一步用来生成数据库数据文件。
2.3.5.4 Initializing the Data Directory
If you installed MySQL using the
Noinstall
package, you may need to initialize the data directory:
Windows distributions prior to MySQL 5.7.7 include a data directory with a set of preinitialized accounts in the
mysql
database.As of 5.7.7, Windows installation operations performed using the
Noinstall
package do not include a data directory. To initialize the data directory, use the instructions at Section 2.10.1.1, “Initializing the Data Directory Manually Using mysqld”.
根据文档所述,在5.7.7以前的Windows发行版都包含了已经预初始化的数据库文件的,但是之后的版本都要用户手动初始化。真烦。
根据文档2.10.1.1 Initializing the Data Directory Manually Using mysqld上所述,结合此次安装具体情况来看,拟定步骤如下:
- 以管理员权限启动cmd
- 进入安装目录
- 执行初始化命令:mysqld.exe --defaults-file=D:\webserver\mysql-5.7.18\my.ini --initialize-insecure
- 因为发现了--defaults-file 选项,为了保险起见,还是用它指定了配置文件的位置
- 使用 --initialize-insecure 而不是--initialize 是因为可以生成一个无密码root账号
然后等就行了...应该没问题吧。过程如图:
哦,对了。有个细节忘记交代。那就是要先建立一个数据库文件夹,然后在配置文件中指明。
我这里就创建在了安装目录下,如图:
本来是个空目录,在执行了初始化之后,里面有了文件,如图:
这一步应该算是成功了。
5.首次启动服务
根据文档,说是执行 mysqld.exe --console 就行了。当然是要在安装目录下。如图:
按文档上来说应该是这样:
To start the server, enter this command:
C:\>"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" --console
For a server that includes
InnoDB
support, you should see the messages similar to those following as it starts (the path names and sizes may differ):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: StartedWhen the server finishes its startup sequence, you should see something like this, which indicates that the server is ready to service client connections:
mysqld: ready for connections Version: '5.7.19' socket: '' port: 3306The server continues to write to the console any further diagnostic output it produces. You can open a new console window in which to run client programs.
然而,我这里是这样的:
不知道这是...但姑且乐观得认为成功了吧。下一步,下一步。
6.通过命令行启动MySQL
通过参考文档,步骤如下:
- 打开cmd
- 进入安装目录下的bin目录
- 输入指令mysql.exe -u root
因为初始化参数的关系,root账户没有密码。过程如图:
到这一步可以说是ok了。
至于第第5步的玄学报错,实在懒得去查文档了,如果哪位读者知道的话还望不吝赐教,不胜感激。
总结
1.启动和关闭服务的方法
启动是在安装目录的bin目录下执行 mysqld.exe --defaults-file=D:\webserver\mysql-5.7.18\my.ini ,关闭的话需要执行 mysqladmin -u root shutdown 。
2.配置文件
我的配置文件只有4行,肯定是不够的,但只是简单使用的话也没问题。总之不在这里扩展了,以后在说吧。
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:MySQL数据库
- mysql7.x如何单独安装mysql 2020-02-27
- linux下如何用源码安装mysql5.6.20 2020-02-27
- MySQL的默认密码的修改方法 2019-10-25
- 安装Mysql时出现错误怎么办 2019-10-25
- PHP7 安装event扩展的实现方法 2019-10-08
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash