Get the App
SLTechnology News&Howtos  ›  Development  › 

How to reinstall mysql in php in linux

Shulou Source: shulou.com Published: 2022-06-03 12:30:47 10月05日 Update

This article is about how to reinstall mysql in php in linux. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Linux PHP re-install mysql: 1. Remove mysql by "sudo apt-get remove mysql-common";2. Clean up residual data;3. Reinstall mysql by "sudo apt-get install".

Operating environment: linux 5.9.8 system, PHP 7.1 version, Dell G3 computer

Linux PHP reinstalling MySQL

MySQL always reports an error, saying that the sock file does not exist, several methods on the Internet, change permissions, change the configuration file, the result is still unable to generate the.sock file normally. No way, delete, reinstall.

Delete completely:

Remove mysql

sudo apt-get autoremove --purge mysql-server-5.0sudo apt-get remove mysql-serversudo apt-get autoremove mysql-serversudo apt-get remove mysql-common //This is very important

Some of the above are actually redundant.

Clean up residual data

dpkg -l |grep ^rc| awk '{print $2}' |sudo xargs dpkg -P But the database file created still exists, and after reinstallation, it can still be used.

install MySQL

sudo apt-get install mysql-serversudo apt-get install mysql-clientsudo apt-get install php5-mysql //install php5-mysql is to connect php and mysql Once the installation is complete, MySQL Server should start automatically. You can check if MySQL Server is running by running the following command at a terminal prompt: sudo netstat -tap| grep mysql When you run this command, you can see lines like the following:

tcp 0 0 localhost.localdomain:mysql *:* LISTEN -

If the server does not function properly, you can start it with the following command:

sudo /etc/init.d/mysql restart

go to the MySQL

$mysql -uroot -p Administrator password

Configure MySQL administrator password:

sudo mysqladmin -u root password newpassword Thank you for reading! About "how to reinstall mysql php in linux" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Tags: File run command data server service content password method more administrator article face residue management configuration good practical important method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei Apple MariaDB Shulou Information