1. Download MySql
https://www.mysql.com/
1. After entering the official website, scroll down to the bottom of the page and click "MySQL Community Server"
2. I downloaded MSI, so I clicked "< MySQL Community Server"
3. Click on the one selected in the red box
4. Continue to click on the red box to select 5.
I downloaded MySQL MSI 5.7 64-bit version
6. Select the red box
2. Install Mysql
1. Double-click the installation package
2. I chose custom installation
Because there are many things that we (novices) do not need, there is no need to install them.
3. Choose what you need to install.
4. Change the installation directory
5. Click "Execute"
6. Next, next, next
7. Click next
8. Set the root account password
9. Click next
10. Click Execute
11. Click next
12. Finish
13. Open "Start Menu"
14. Enter the password
(test whether mysql is configured successfully: open cmd, enter "mysql -u root -p" and press Enter, then enter the password of the root account set during mysql installation (Dw.2016%), if The prompt "Welcome to the MySQL monitor." indicates that the configuration is successful). If you enter mysql in the console (cmd) window of the computer and it prompts: It is not an internal or external command or a runnable program, you need to configure the mysql environment variable. .
3. Environment configuration
1. Add a system variable, click New, the variable is named: MYSQL_HOME, the variable value is: mysql installation directory
description: After configuring the environment variable for mysql, we can run mysql in cmd (start, stop, etc.) )
2. In the system variables, click "Path", create a new one, enter: %MYSQL_HOME%\bin
3. Select "path" in the system variable, enter the path to the bin folder in the mysql installation directory at the beginning of the path value: C:\Program Files\MySQL\MySQL Server 5.7\bin, save and exit 4. Verify that cmd
enters
win Terminal, enter: mysql -Version
This is it! success!
1. Possible errors
mysql -Version, V needs to be capitalized.
"'mysql' is not recognized as an internal or external command, operable program
or batch file." Environment variables do not take effect. Run cmd as administrator, or restart, otherwise the environment variables are misconfigured.
****5. Some MySql commands
- Start the mysql service
Note: mysql57, the name during installation. That is "window service name". If you have forgotten it, see "2. Step 9 of installing Mysql"
net start mysql57 - Stop mysql service
net stop mysql57 - Check the version of mysql
mysql -Version - Log in to mysql
mysql -u'username' -p'password'****
- View the MySQL installation directory (you need to log in to mysql first)
show variables like “%char%”; 6. View the physical file storage location of the mysql database (you need to log in to mysql first)
show global variables like “%datadir%”; - Check the character set of mysql (you need to log in to mysql first)
show variables like '%char%'; - Modify the character set of mysql (you need to log in to mysql first)
set character_set_connection=utf8; - MySQL exit
1.\exit
2.\quit
, Start mysql
Yes, we have not started our mysql yet! So how to start it?
(Based on the situation where environment variables have been configured)
2. After prompting that the startup is successful, we can see the "mysqld.exe" process in the process of the task manager.
Attachment:
If when executing the command, it prompts: The service name is invalid. Please type NET HELPMSG 2185 for more help.
Solution: Execute the mysqld -install command with administrator privileges in the mysql bin directory
Attachment: How to uninstall the mysql service.
1. Use the administrator authority net stop mysql to close the mysql service.
2. Use the administrator authority mysqld -remove to uninstall the mysql service.
Close and start the mysql database command
net stop mysql to close the database
net start mysql to start the database.