Home >Database >Mysql Tutorial >What should I do if mysql cannot connect to the database?
Solution: First press the "win r" key on the keyboard to open the run window; then enter "services.msc" in the window and press the Enter key on the keyboard; then double-click mysql with the mouse. In the pop-up window, select "Automatic" for "Startup type", click "Start", select "Apply"; finally click the "OK" button.
The operating environment of this tutorial: windows7 system, mysql8.0 version, Dell G3 computer.
When opening the DOS window and entering the mysql connection command, the error message "Cannot connect to MySQL server on 'localhost' (10061)" is prompted, as shown below:
The cause of the above problem may be that the local service is not turned on. You need to turn on the local service. Press Win r to run this command. In the pop-up window, enter services.msc and hit Enter, as shown below:
Find MySQL and double-click it, as shown below:
After double-clicking, this box will pop up. Select "Automatic" for the startup type, click the "Start" button, click the "Apply" button, and click the "OK" button, as shown below:
## Next, you can connect to the local MySQL database, as shown below:
Related recommendations: "mysql tutorial"
The above is the detailed content of What should I do if mysql cannot connect to the database?. For more information, please follow other related articles on the PHP Chinese website!