These two days installed a MySQL database on their windows7, which was installed using the 5.7.18 version of the Noinstall ZIP Archive installation package Mysql-5.7.18-win32.zip. Since the 5.7 version of the relative 5.6 version of the changes, many online installation tutorials are invalid, so in the installation process encountered a series of problems, here according to their own view of the official documents and the actual resolution process, the installation of a high version of the MySQL install procedures, I hope to be helpful. The detailed steps are as follows:
1. Download the installation package
Download the installation package from the Https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.18-win32.zip path and unzip:
One of the benefits of using the Noinstall ZIP Archive installation package is that the installation process is relatively straightforward and does not require a visual installation step-by-step, as in the case of an MSI installation package.
Note: starting with version 5.7.7, the installation package does not contain the data directory, the data directory needs to be initialized to generate (MySQL official original: As of 5.7.7, Windows installation operations performed Using the package does not Noinstall
include a data directory.). also, starting with version 5.7.18, because the. ini profile is no longer included in the distribution package .
2. Initialize the Data directory
In order to initialize the data directory, you can call mysqld --initialize
或者
mysqld-initialize-insecure
,
这两者的区别是
mysqld --initialize
会生成一个随机密码,该密码存在于
mysql
错误日志文件中,而mysqld-initialize-insecure
会为
root‘@‘localhost
创建一个空密码,以后在连接数据库时可以不必输入密码。
官方建议使用
mysqld-initialize-insecure
,以防止你在连接数据库过程中忘记密码。初始化
data
目录过程如下:
2.1 Run as Administrator cmd.exe
2.2 Execution: mysqld --initialize
Enter the D:\software\mysql\mysql-5.7.18-win32\bin,
Since I've already done this before, I've initialized the data directory, so the hint here already exists. If you are doing this for the first time, you will see that the D:\SOFTWARE\MYSQL\MYSQL-5.7.18-WIN32 directory has more data directories.
2.3 Viewing random passwords
Since I am using mysqld --initialize
to initialize and generate the data directory, a random password is generated and written to the error log file: D:\software\mysql\mysql-5.7.18-win3\data directory under *. Err named file with the Write format: A temporary password is generated for [email protected]: 2rhhs?elm3h*.
3. Install MySQL
D:\software\mysql\mysql-5.7.18-win32\bin> Mysqld-install
will prompt success. Note: If you install denial, you will need to have CMD open as an administrator.
4. Start the service
D:\software\mysql\mysql-5.7.18-win32\bin>net start MySQL
To stop the service, execute the net stop mysql command
5. Modifying environment variables
Add the D:\software\mysql\mysql-5.7.18-win32\bin path to the system environment variable, because you will connect and run the MySQL command directly under the cmd login path, without having to re-enter the CD d:\ Software\mysql\mysql-5.7.18-win32\bin before the MySQL command can be executed. The steps for how to set environment variables under Windows are as follows:
5.1 New environment variable Mysql_home
Computer-"Right-click Properties-" Advanced system Settings-advanced-"Environment variables-" System Variables-"NEW:
Create an environment variable named Mysql_home with a value of D:\software\mysql\mysql-5.7.18-win32.
5.2 Adding%mysql_home%\bin to the PATH variable
In the path variable, add "%mysql_home%\bin;", OK.
6. Connect to the database
After completing the MySQL installation and setting the environment variables, you can run Cmd.exe and execute the Connect command.
1) If you are initializing the data directory via--initialize, you will need to enter a random password when connecting.
If you forget the random password, you can go to the *.err error log file to find the random password. If your *.err accidentally deleted by you, then please refer to the 8th section, change the password.
2) If you are using --initialize-insecure
the initialized data directory, you can not apply the password.
- shell>
mysql -u root --skip-password
7. Connection test
When the connection is successful, you can perform the status; command to see the configuration of the database.
8. Change the password
Method One: (Usage scenario: After a successful connection, set a new password)
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘new_password‘;
Method Two: (Use the scene: Forget the password, how to find also can not find)
6. Quit logout system.
7, reconnect, enter a new password.
This completes the process of installing MySQL under the Windows7 platform.
Reference Documentation:
Https://dev.mysql.com/doc/refman/5.7/en/windows-install-archive.html
Installing MySQL on Microsoft Windows Using a noinstall Zip Archive