Home > Article > Backend Development > How to reinstall mysql in linux php
linux php method to reinstall mysql: 1. Delete mysql through "sudo apt-get remove mysql-common"; 2. Clean up the residual data; 3. Reinstall mysql through "sudo apt-get install" that is Can.
The operating environment of this article: linux5.9.8 system, PHP7.1 version, Dell G3 computer
linux php reinstall mysql
MySQL always reports an error, saying that the sock file does not exist. I tried several methods online, changed permissions, and changed the configuration file, but the result was that the .sock file still could not be generated normally. No way, delete and reinstall.
Completely delete:
Delete mysql
sudo apt-get autoremove --purge mysql-server-5.0 sudo apt-get remove mysql-server sudo apt-get autoremove mysql-server sudo apt-get remove mysql-common //这个很重要
Some of the above are actually redundant.
Clean up residual data
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P but the created database file still exists. After reinstallation, it still exists can use.
Install mysql
sudo apt-get install mysql-serversudo apt-get install mysql-clientsudo apt-get install php5-mysql //Installing php5-mysql is Once the installation is complete, the MySQL server should start automatically. You can check if the MySQL server is running by running the following command from the terminal prompt: sudo netstat -tap | grep mysql When you run the command, you can see lines similar to the following:
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
if server If it cannot run normally, you can start it with the following command:
sudo /etc/init.d/mysql restart
Enter mysql
$mysql -uroot -p administrator password
Configure the administrator password for MySQL:
sudo mysqladmin -u root password newpassword
Okay, done.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to reinstall mysql in linux php. For more information, please follow other related articles on the PHP Chinese website!