First, let's introduce my What's the use of ini folder: my Ini is the configuration file used in the MySQL database. This configuration file will be read when the MySQL server starts. We can update the configuration by modifying this file.
my. If the INI file does not exist, you can first look at my Is the INI file hidden under the ProgramData file? If it cannot be found and there is no global search, follow the following steps!!
Let me first write a thought: pause mysql Service -- uninstall mysql Service -- create my Ini folder -- delete the data file and regenerate the data file -- install mysql service and bind my INI file -- restart mysql Service -- reset password
First open cmd and enter the mysql installation directory
1. Pause mysql service:
net stop mysql
2. Delete mysql service:
sc delete MySql
3. Create my INI file and copy the following contents to the folder. You can first put the file on the desktop and then cut it to the mysql installation path.
# 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_bin 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 = mysql Installation path datadir = mysql Installation path\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. Delete the data file. The data file is mainly used to store data. If any data needs to be retained, please backup it in advance. After deletion, the data file will be regenerated in cmd and wait for a while. (no prompt after generation)
mysqld --initialize-insecure --user=mysql
5. Install mysql server and bind my INI file
mysqld --install "MySql80" --defaults-file="C:\Program Files\mysql\MySQL"
mysql 80 represents version 8.0 of mysql. The specific version can be searched on the Internet.
After successful installation, open the "service" window of the computer to find the newly added mysql 80 service. You can right-click to enable it manually or start the mysql service using the command line
net start mysql
6. Set password
Since we deleted the data file, the password needs to be reset. We enter mysql without entering the password and enter directly
mysql -u root -p
After entering mysql, we can change the password
Note: the password modification method after mysql 8.0 is
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Your password';
Before
update mysql.user set authentication_string=password("Your password") where user="root";
I installed 8.0 11, so we use the first one
Finally, just log in again!!
I saw this method when I encountered this problem, although there are still modifications on the Internet INI file, but I don't have my Ini, so I created a new my INI file
Access denied for user'root'@'localhost' (using password: YES)