The Tencent Cloud server reinstalled very quickly, taking about a minute. Once logged in, systemctl status mysql showed that the service was running. I started searching for the password but couldn’t find it anywhere, and I began to panic.
Then, I thought, since I had already accessed the server with root privileges, there must be a way to reset the password. I searched through documentation and found a forum post on Alibaba Cloud’s forum, continuing to tinker.
Reset Password
Edit the configuration file vim /etc/my.cnf, add the following configuration to the mysqld node: skip-grant-tables, and execute the command to restart the database: systemctl restart mysql.
Then, log in directly to the data using mysql, after which everything will proceed normally. To reset the root user password and enable allowing remote login simultaneously:
USE mysql;
UPDATE user SET authentication_string = password('pass') WHERE User = 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'pass' WITH GRANT OPTION;
FLUSH PRIVILEGES;
To revert the modified configuration file, restart the database, and you’re done.