1. Download
MySQL download address: https://dev.mysql.com/downloads/mysql/
Two, placement
Because the download is in .zip format, it is not necessary to install it. It can be used after decompression and configuration.
1. After decompressing, rename the folder to: MySQL Server 5.7.21, and put it in the D:\Tools\MySQL path (which can be stored according to your own needs);
2. Configure environment variables
Right-click on the computer-->Properties-->Advanced System Settings-->Advanced (Environment Variables), append it after the path; D:\Tools\MySQL\MySQL Server 5.7.21\bin (note that it is appending, not overwriting)
3. Create a new data folder and my.ini under MySQL Server 5.7.21.
Configure my.ini, modify basedir and datadir to the corresponding addresses, as follows:
basedir = D:\Tools\MySQL\MySQL Server 5.7.21
datadir = D:\Tools\MySQL\MySQL Server 5.7.21\data
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init_connect='SET NAMES utf8mb4' # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir = D:\Tools\MySQL\MySQL Server 5.7.21 datadir = D:\Tools\MySQL\MySQL Server 5.7.21\data port = 3306 # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 16M read_rnd_buffer_size = 16M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
4. Installation
Go to the D:\Tools\MySQL\MySQL Server 5.7.21\bin folder, enter cmd in the address bar and press Enter, and enter mysqld -install (if that doesn't work, try running it as an administrator).
Service successfully installed. --Prompt that the installation was successful
5. Run/Stop the service
After the installation is successful, you need to start the service. Continue to enter: net start mysql in cmd (as shown in the figure). The service starts successfully!
Continue to enter in cmd: net stop mysql (as shown in the figure), the service stops successfully!
6. Enter MySQL
Enter mysql -u root -p (there is no password for the first login, just press Enter), the login is successful! -- I checked a lot of tutorials on the Internet, but goose, I actually failed
Solution:
(1) My.ini file, find [mysqld]
this item in it, then add this configuration under the configuration item skip-grant-tables
, and then save the file.
(2) Restart the mysql service. net stop mysql / net start mysql
(3) Enter mysql -u root -p, press Enter, and the login is successful! haha~
(4) Change the password
The versions below mysql5.7 are as follows:
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='127.0.0.1' or host='localhost';//put an empty user password Just change it to a non-empty password.
The mysql5.7 version is as follows:
update mysql.user set authentication_string=password('newpassword') where user='root' and host='127.0.0.1' or host='localhost';
mysql> FLUSH PRIVILEGES;mysql> quit # /etc/init.d/mysqld restart //Leave and restart mysql
# mysql -uroot -p
Enter password: <Enter the new password newpassword>
OK~ Done!