Windows installation MySQL5.7 Tutorial

REVIEW:
Our daily study may need to install the MySQL service locally, also encountered a small partner to explore questions about Windows system installed MySQL. Here suggest that you install MySQL5.7 version, of course, I want to try the 8.0 version of the students also can refer to the installation. This article to MySQL5.7.23 version, for example, a step by step as we summarize the installation steps, we want to help!

1. Check and uninstall the original version

Under our system, we can check the service determines that there is no case had two MySQL installed, open the Windows system services are:

  1. Right-click on My Computer / Computer, click Manage to open Computer Management, select services and applications - services.
  2. Use the shortcut command: win + r key while pressing Enter services.msc in the Run window to open the service.

Open the System Services page below, you can see my computer has been installed MySQL, here I uninstall it, if your computer does not have MySQL service is not required to operate this step.
Windows installation MySQL5.7 Tutorial

Now we open the cmd command line to uninstall MySQL:

  1. Stop MySQL service

  Windows installation MySQL5.7 Tutorial

  1. Uninstall MySQL

  Windows installation MySQL5.7 Tutorial

2. Download the MySQL installation package

download link:
https://downloads.mysql.com/archives/community/

Select the Windows download version 5.7.23
Windows installation MySQL5.7 Tutorial

3. Extract the installation package and configure the environment variables

The compression bag on a suitable disk decompression, I am here on the E drive, unzip the folder recommend rename mysql5.7.23.
Windows installation MySQL5.7 Tutorial
Before the proposed installation to configure the environment variables:
Right-click My Computer / Computer, click Properties to open the Advanced System Settings, click Environment Variables.
Variable Name: MYSQL_HOME
variable values: E: \ mysql5.7.23
path was added:% MYSQL_HOME% \ bin

4. Create a data directory and configuration files

This version of MySQL does not create data directory and my.ini. Create a data directory under MYSQL_HOME directory, it is recommended data directory to E: \ mysql5.7.23 \ data. In addition, create Uploads directory as the MySQL import export directory. my.ini put the proposal under MYSQL_HOME directory, simple configuration, see:

[mysqld]
port=3306
character_set_server=utf8
basedir=E:\mysql5.7.23
datadir=E:\mysql5.7.23\data
server-id=1
sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
lower_case_table_names=1
innodb_file_per_table = 1
log_timestamps=SYSTEM

log-error   = error.log
slow_query_log = 1
slow_query_log_file = slow.log
long_query_time = 5
log-bin = binlog
binlog_format = row
expire_logs_days = 15
log_bin_trust_function_creators = 1
secure-file-priv=E:\mysql5.7.23\Uploads

[client]   
default-character-set=utf8

After the completion of our directory structure become so
Windows installation MySQL5.7 Tutorial

5. initialize the database

cmd command line to enter the E: \ mysql5.7.23 \ bin directory, execute mysqld --initialize-insecure
Windows installation MySQL5.7 Tutorial
after the execution is completed, the data in the directory will generate a lot of files.
Windows installation MySQL5.7 Tutorial

6. register and start MySQL service

Execute mysqld -install MySQL57 installation services (install followed by the name of the service, we are here to MySQL57 as the service name mysql5.7) net start MySQL57 start the MySQL service.
Windows installation MySQL5.7 Tutorial

7. Log in and change your password

To remind you that due to the initial setting or differences between versions, some versions after installation is complete root password is empty, some are temporary password, we need to see the error log logs tips.
Windows installation MySQL5.7 Tutorial
Open the error log and found that I have here is a blank password.
Windows installation MySQL5.7 Tutorial
Now we command line login modifications Password:
Windows installation MySQL5.7 Tutorial
If you need to configure remote access to the root user, you can execute the following statement:
Windows installation MySQL5.7 Tutorial
Then we can log in using tools such as Navicat!
Windows installation MySQL5.7 Tutorial

8. supplied backup script

It presented additional logical backup script oh, if you want to back up every day, can be added to script scheduled tasks, the timing to perform every day.
We can create a MySQLdata_Bak under the E disk directory, create a directory to store the backup files mysql_backup this directory, mysql_bak.bat backup script, the script reads as follows (automatically delete backup files older than 7 days):

rem auther:wang
rem date:20190526
rem ******MySQL backup start********
@echo off
forfiles /p "E:\MySQLdata_Bak\mysql_backup" /m backup_*.sql -d -7 /c "cmd /c del /f @path"
set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%"
"E:\mysql5.7.23\bin\mysqldump" -uroot -p123456 -P3306 --default-character-set=utf8 -R -E --single-transaction  --all-databases > "E:\MySQLdata_Bak\mysql_backup\backup_%Ymd%.sql"
@echo on
rem ******MySQL backup end********

Overall directory structure is as follows, mysql_bak.bat script to back up all of our database, double-click to run under.
Windows installation MySQL5.7 Tutorial


No public .jpg

Guess you like

Origin blog.51cto.com/10814168/2402109