Recently, I am learning the content of the imitation site and need to use phpstudy. After downloading phpstudy, I want to start the MySQL service, but it always fails to start.
The main reason is that a MySQL service has been installed locally before, and the MySQL service in phpstudy and the local MySQL both occupy port 3306, resulting in a conflict.
However, it is very troublesome to modify the port number of any service, and you don't want to uninstall the MySQL service that was installed locally, so you can use the following methods to solve the service conflict:
- First press win+R to execute services.msc to enter the service, find MySQL, click to stop the service, and then enter the local MySQL folder in the console cmd, my file name is mysql-8.0.26-winx64, execute the command after entering
sc delete mysql
To delete the service, it is found that the deletion cannot be performed because the operation must be performed as an administrator. - After the deletion is successful, the MySQL database on phpstudy will be automatically started.
- If you want to restart the local MySQL service, enter the mysql-8.0.26-winx64 folder as an administrator and execute the command
mysqld --install
- Then win+R execute services.msc to enter the service and start the MySQL service
- found that the service could not be started
However, the MySQL in phpstudy can also be used after it is started. If you really want to use the local MySQL, you can use the following methods to solve the problem of not being able to start.
- First delete the unstartable service as an administrator:
sc delete mysql
- Initialize the mysql service:
mysqld --initialize
, a data file will be generated in the mysql installation directory
- Install MySQL service:
mysqld -install
- Reinitialize once:
mysqld --initialize-insecure
- Then install the service again:
mysqld -install
- After entering the bin directory, start the service:
net start mysql
- Started successfully:
Although this method can successfully start the MySQL service, it essentially resets everything in the original MySQL, which means that the originally established database disappears and the original password cannot enter the database. It is necessary to modify the password of the MySQL database. can go in.
Since many versions for changing MySQL database passwords are outdated, I found a newer article to change the password. The blogger's MySQL database version is 8.0.19, while mine is 8.0.26. The method can successfully change the password.
Reference link: CSDN blog - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) solution