Article reference: https://blog.csdn.net/wengengeng/article/details/52013650
foreword
Install the mysql database today and enter the mysql official website. For windows, there are two versions of the files available for download, one is the .msi installation file, and the other is the .biz compressed package. I have been using the installation file to install it before, and I have been unsuccessful. Today I suddenly don't want to use the installation file, it's time to install it with a compressed package. So I downloaded the compressed package and searched for some installation tutorials. The installed mysql service always reported an error. I looked for the tutorial again, but the service still could not be started...
So, I don't trust Baidu anymore. Enter the mysql official website and find the documentation of mysql5.7: http://dev.mysql.com/doc/refman/5.7/en/installing.html, step by step, finally succeeded.
download mysql
- Enter the official website: https://www.mysql.com/
- Click the [Downloads] tab
- At the bottom there is a【
MySQL Community Edition
(GPL) ], click【Community (GPL) Downloads »】 - Click [DOWNLOAD] under [ MySQL Community Server (GPL) ]
- https://dev.mysql.com/downloads/mysql/ Select the version to download
- Download 【 Windows (x86, 64-bit), ZIP Archive】on the pop-up page
install mysql
The compressed package is equivalent to an installation-free file. To use it, you need to configure it correctly and start the database service through the service.
This example is extracted to: D:\mysql-5.7.13-winx64, under the folder
- [mysqld]
- port=3306
- basedir ="D:\\mysql-5.7.13-winx64\\"
- datadir ="F:\\mysqlData\\"
- max_allowed_packet = 32M
Since I like to separate the data files of the database, I configure the datadir to other places to facilitate management. Also, create the directory.
3. Configure environment variables
- Add a variable called MYSQL_HOME.
- Modify the Path variable and add %MYSQL_HOME%\bin at the end.
- Note: After setting the environment variables, the runtime library is missing: vcredist_x64.exe is missing msvcp120.dll, so you have to download the runtime library at https://www.microsoft.com/en-us/search/result.aspx?q= Search for Visual Studio 2013 and find
visual studio 2013 download, and find
Update for Microsoft Visual Studio 2013 Update 4 (KB3023304), there is a genuine runtime library, just download and install.
4. Install mysql service
- Run cmd as an administrator and enter the bin directory of mysql.
- Initialize the database file
- mysqld --initialize
- 2016-07-24T05:19:20.152135Z 1 [Note] A temporary password is generated for root@localhost: bL2uuwuf0H(X
That is, the password is: bL2uuwuf0H(X
- register mysql service
- mysqld -install MySQL
- start mysql service
- net start MySQL
- Change root password
Type the following command, hit enter, and enter the default password above:
- mysql -u root -p
After entering the MySQL command line mode, enter the following command. The
new_password
in the command is the new password of the root account. Please modify it.
- ALTERUSER'root'@'localhost' IDENTIFIED BY'new_password';