Engaged in development for many years, in fact, MySQL and the installation of many times, but each need to search the online tutorial, toss half a day to fix, this time simply the whole process of recording down, in order to consult later.
Download
To the MySQL official website, navigate to the DOWNLOADS>>Community>>MySQL Community Server page, or click here directly to Select the appropriate MySQL version of the zip package, and here I am mysql-5.7.21-winx64.zip.
Installation configuration
- After downloading the compressed package, unzip it directly to the directory that will be stored;
- Create a new file in the root directory
my.ini
(and no so-called my-default.ini
file), save it as an ANSI
encoded format, such as:
-
Copies the following code into My.ini
:
[mysql]< Span class= "CO" ># set MySQL client default character set Default- character- set = utf8[mysqld]# set 3306 ports port = 3306 # set the installation directory for MySQL basedir= D: \\ Program Files\\ mysql-5.7.21 # allow maximum number of connections Max_ Connections= 200 # the character set used by default is a 8-bit encoded latin1 character set character- set - server = utf8# default storage engine to be used when creating new tables Default- storage< Span class= "OP" >- engine= INNODB
- under D:\Program files\mysql-5.7.21\bin directory, press and hold shift+ right-click , select Open Command Window here ;
- Execute command
mysqld--install
, you may receive the following errors:
- Install/remove of the Service Denied br> This problem occurs because the permissions to execute the command are insufficient, locate the
cmd.exe
file in the C:\Windows\System32 directory, and re-run as Administrator Open the cmd window, and then go to the D:\Program files\mysql-5.7.21\bin directory and execute the mysqld--install
command again.
- missing Msvcr120.dll,msvcp120.dll
The problem is obvious, lack of files, what is missing, many online programs, The simplest way is to install the corresponding version of the VC + + Runtime installation package According to the missing files, because MSVCR and MSVCP are all part of VC + + Runtime library, as follows:
MSVCP, MSVCR, Vcomp140.dll belongs to vc++2015 edition MSVCP, MSVCR, Vcomp120.dll belong to vc++2013 version msvcp, MSVCR, Vcomp110.dll belongs to vc++2012 version msvcp, MSVCR, Vcomp100.dll belongs to vc++2010 version MSVCP , MSVCR, Vcomp90.dll belong to vc++2008 version MSVCP, MSVCR60, 71 and 80.dll, and Vcomp.dll (without the digital version number) belong to the vc++2005 edition
- Found option without preceding group in config file
This error generally occurs when the My.ini
file header is missing [MySQL]
, or another case where the file is encoded in a wrong format, save the file encoding as ANSI
.
- Executes the command
mysqld --initialize
, where the folder is automatically generated under the installation root directory data
(the original directory does not have the folder).
Execute net start mysql
the command to start the service, such as to prove that the installation was successful.
Configure account password
But when we enter mysql
a command, the following error occurs.
In fact, we did not set any password, the workaround is as follows:
- Open the file in the MySQL directory
my.ini
, add a line at the end of the file skip-grant-tables
, save and close the file.
- Restart the MySQL service.
- Enter (without entering a password) on the command line and enter the
mysql -uroot -p
database.
- Execute the SQL statement
use mysql;
using the MySQL database.
- Executes the SQL statement
update user set authentication_string=password(‘123456‘) where user=‘root‘;
.
- Open the files in the MySQL directory
my.ini
, delete the last line skip-grant-tables
, save and close the file.
Restart the MySQL service.
Note:
At this point, if you perform such use mysql
commands, you may see the must reset your password using ALTER USER statement before executing this statement. Error, if present, perform the following steps:
Execution of orders SET PASSWORD = PASSWORD(‘123456‘);
;
Executes the command ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;
.
Turn on remote connections
- Execution of orders
MySQL -uroot -p123456
;
- Execution of orders
use mysql;
;
- Execution of orders
update user set host = ‘%‘ where user = ‘root‘;
;
- The Execute command
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
gives any host permission to access the data.
Mysql-5.7.21 installation Configuration