Use the binary package to install the MySQL database under the window system


Window system uses binary package to install MySQL database


The following is only what I have touched during my work and study. I welcome any deficiencies.

Installation Notes

1. The window system where the database is installed is Win7 Professional 64-bit
2. The MySQL version is mysql-5.7.17-winx64

Download and unzip

Download address: https://downloads.mysql.com/archives/community
Select the corresponding version to
p
download according to the following figure: After downloading, unzip to the installation directory: D: \ Software_Installed \ mysql-5.7.17
p

Create a directory

Create data file storage directory: D: \ MySQL \ Data
Create log file storage directory: D: \ MySQL \ Log

Create my.ini

Create the my.ini file in the database installation directory (D: \ Software_Installed \ mysql-5.7.17), and write the following content to the file:

[client]
no-beep
socket =0.0
port=3306
[mysqld]
server-id=45
port=3306
character-set-server=utf8mb4
pid-file ="mysql.pid"
socket =0.0
basedir="D:\Software_Installed\mysql-5.7.17"
datadir="D:\MySQL\Data"
tmpdir="D:\MySQL\Data"
default-storage-engine=INNODB
#=============================[log]==============================
slow-query-log=1
long_query_time=1
slow_query_log_file="D:\MySQL\Log\mysql-slow.log"
##log-bin="D:\MySQL\Log\mysql-bin"
log-error="D:\MySQL\Log\mysql-error.log"

Initialize the database

Open the cmd window and switch to the following directory: D: \ Software_Installed \ mysql-5.7.17 \ bin
execute the following command to initialize the database

mysqld --defaults-file="D:\Software_Installed\mysql-5.7.17\my.ini" --initialize --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp

After the initialization is complete, open the file D: \ MySQL \ Log \ mysql-error.log to view the temporary password generated during initialization, which will be used when logging in to mysql for the first time
p

Configure environment variables (optional)

Add in the system environment variables:

D:\Software_Installed\mysql-5.7.17\bin

Add mysql service

Need to add / delete service as administrator
Add service

mysqld install MySQL --defaults-file="D:\Software_Installed\mysql-5.7.17\my.ini" 

Delete service

mysqld remove

Start and stop

It requires an administrator to start / stop the service
start

net start mysql

stop

net stop mysql

First login and change user password

cmd login mysql, the password is the password generated during initialization, can be found in the file D: \ MySQL \ Log \ mysql-error.log

mysql -uroot -p

Change user's password

alter user root@"localhost" identified by "new_password";

drop out

\q

Possible errors during installation

1. Net start mysql reports an error
p
Solution: Open cmd as an administrator, right-click cmd-> Run as administrator
p
2. Error registration / deletion service
p
solution: Open cmd as an administrator, right-click cmd -> Run as administrator
3. Log in to mysql failed, ERROR 1045 (28000): Unknown error 1045
p
Solution: Add skip- under [mysqld] in file D: \ Software_Installed \ mysql-5.7.17 \ my.ini grant-tables, skip the authorization table, that is, log in without password and restart the service.
p

reference

Guess you like

Origin www.cnblogs.com/hai-feng/p/12717045.html