MySQL 5.7 has been used before, but since MySQL has added some new features, it has chosen to update.
Download MySQL
Enter the MySQL official website download address, select windows (x86, 64 bit), zip archive.
Download address: https://dev.mysql.com/downloads/mysql/
You can skip without logging in. Download process may be lost slowly, wait patiently.
After downloading, directly decompress to your favorite location.
Uninstall the original version
If you have previously installed a lower version of MySQL, you need to uninstall the previous MySQL first. If not, skip this step directly.
The administrator opens cmd, stops MySQL service with net stop, and then uses mysqld remove MySQL to remove mysql.
net stop mysql mysqld remove MySQL
Delete the registry information to avoid that the new version cannot be installed normally sometimes. Delete if any, but only the first one exists when I operate.
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Application/MySQL HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services/Eventlog/Application/MySQL HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Application/MySQL
Modify the environment variable of the original MySQL home to point to the new version location.
Install MySQL
In the MySQL unzip directory, create a new data folder, and create my.ini configuration file.
[mysqld] # Set 3306 port port=3306 # Set the installation directory of mysql basedir=E:\\tools\\MySQL\\mysql-8.0.18-winx64 # Set the storage directory of mysql database data datadir=E:\\tools\\MySQL\\mysql-8.0.18-winx64\\data # Maximum connections allowed max_connections=3000 # The number of connection failures allowed. This is to prevent someone from trying to attack the database system from the host max_connect_errors=10 # The character set used by the server defaults to UTF8 character-set-server=utf8 # Default storage engine to use when creating new tables default-storage-engine=INNODB [mysql] # Set mysql client default character set default-character-set=utf8 [client] # Set the default port when mysql client connects to the server port=3306 # Set the default character set when mysql client connects to the server default-character-set=utf8
Enter the bin directory and execute mysqld --initialize --console. If the execution is successful, the temporary password will be output.
mysqld --initialize --console After successful execution, it will output: A temporary password is generated for root@localhost: a4lcly4e8f-G a4lcly4e8f-G is the temporary password
Then the password can be used. If you are lucky, you can enter MySQL normally.
Login error
ERROR 1045 (28000):Access denied for user 'root'@'localhost' (using password: YES).
Encountered this problem, password verification needs to be skipped.
Stop MySQL service first: net stop mysql
In the bin directory of MySQL installation path, enter mysqld -- console -- skip grant tables -- shared memory. At this time, the cmd window will be suspended, that is to say, it looks stuck. Don't worry. This is a normal phenomenon.
Then open another window, which is also the bin directory of MySQL installation path. Enter MySQL directly and execute use mysql.
Use flush privileges to refresh the permissions, and then alter user'root'@'localhost' IDENTIFIED BY '1234'; change the password.
To be sure, use flush privileges again to refresh permissions.
Close the window, reconnect MySQL with the password you just used: mysql -u root -p, and then enter the password. If the service is not started, you need to start MySQL service first, and enter net start mysql.
# Close MySQL net stop mysql # Skip permission verification mysqld --console --skip-grant-tables --shared-memory # Refresh authority flush privileges # --Connect MySQL in skip grant tables mode mysql # Using system mysql Library use mysql # Change password alter user 'root'@'localhost' IDENTIFIED BY '1234'; # Refresh authority flush privileges # Connect MySQL, - u, - p spaces can be omitted, - p spaces can be omitted, - p spaces can not be used to enter a password, and then enter a password, which is more secure mysql -u root -p 1234 # Quit MySQL \q exit quit