MySql_Win_Install - daaoling/daaoling.github.io GitHub Wiki
MySQL Version 5.7.9-winx64 uninstall zip archive
TP:FCEE652B
default use uninstall zip archive, same as installer
- Extract the main archive to the desired install directory
- Create an option file
- Starting the Server for the First Time
- Starting MySQL as a Windows Service
- Result
Traditionally, the MySQL server is installed in
C:\mysql
The MySQL Installation Wizard installs MySQL under C:\Program Files\MySQL. If you do not install MySQL at C:\mysql, you must specify the path to the install directory during startup or in an option file.
To make it easier to invoke MySQL programs, you can add the path name of the MySQL bin directory to your Windows system PATH environment variable
example, C:\mysql\bin
You should not add the MySQL bin directory to your Windows PATH if you are running multiple MySQL servers on the same machine
MySQL looks for options in each location first in the my.ini file, and then in the my.cnf file. However, to avoid confusion, it is best if you use only one file. If your PC uses a boot loader where C: is not the boot drive, your only option is to use the my.ini file. Whichever option file you use, it must be a plain text file
if not exit in zip file (5.7.x you shuld create by you self)
An option file can be created and modified with any text editor, such as Notepad. For example, if MySQL is installed in C:/mysql and the data directory is in C:/mysql/data, you can create an option file containing a [mysqld] section to specify values for the basedir and datadir options:
[mysqld]
# set basedir to your installation path
basedir=C:/mysql
# set datadir to the location of your data directory
datadir=C:/mysql/data
As of MySQL 5.7.6, the Zip Archive no longer includes a data directory. To initialize a MySQL installation by creating the data directory and populating the tables in the mysql system database, initialize MySQL using either --initialize or --initialize-insecure depending on whether you want the server to generate a random initial password for the 'root'@'localhost' account. For additional information, see Section 2.10.1.1, Initializing the Data Directory Using mysqld
mysqld --initialize-insecure --user=mysql
(不同版本的mysql初始化方式不一样,具体看data-directory-initialization-mysqld)
Prior to 5.7.6, use mysql_install_db on Unix and Unix-like systems
Prior to MySQL 5.7.7, Windows distributions include a data directory with prebuilt tables in the mysql database.
--initialize-insecure 生成一个空密码
--initialize 生成一个随机密码
If you would like to use a data directory in a different location, you should copy the entire contents of the data directory to the new location. For example, if you want to use E:\mydata as the data directory instead, you must do two things
1.Move the entire data directory and all of its contents from the default location (for example C:\Program Files\MySQL\MySQL Server 5.7\data) to E:\mydata.
2.Use a --datadir option to specify the new data directory location each time you start the server.
To start the mysqld server from the command line, you should start a console window (or “DOS window”) and enter this command:
C:\> C:\mysql\bin\mysqld
You can stop the MySQL server by executing this command:
C:\> C:\mysql\bin\mysqladmin -u root shutdown
If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.
On Windows, the recommended way to run MySQL is to install it as a Windows service, so that MySQL starts and stops automatically when Windows starts and stops Generally, to install MySQL as a Windows service you should be logged in using an account that has administrator rights.
The Services utility can be found by services.msc
Before installing MySQL as a Windows service, you should first stop the current server if it is running by using the following command:
C:\> C:\mysql\bin\mysqladmin -u root shutdown
If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.
This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system.
C:\> C:\mysql\bin\mysqld --install
Once a MySQL server has been installed as a service, Windows starts the service automatically whenever Windows starts. The service also can be started immediately from the Services utility, or by using a NET START MySQL command. The NET command is not case sensitive
net start mysql (or net stop mysql to stop service)
To remove a server that is installed as a service, first stop it if it is running. Then use the --remove option to remove it:
C:\> "C:\mysql\bin\mysqld" --remove

my.ini:
[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci

Troubleshooting a Microsoft Windows MySQL Server Installation
#2016-2-23
有一次重装碰到以下错误:
C:\Users\Administrator>mysqld --install
The service already exists!
The current server installed: "C:\Program Files\MySQL\MySQL Server 5.7\mysqld" M
ySQL
和我装的路径不对
C:\mysql
所以你就进到 C:\mysql\bin 目录
然后再 mysqld --install 就可以了
C:\mysql\bin>mysqld --install
Service successfully installed.
C:\mysql\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。