Home > Database > Mysql Tutorial > body text

Ubuntu下彻底卸载并重新安装MySQL_MySQL

WBOY
Release: 2016-06-01 13:13:59
Original
1120 people have browsed it

Ubuntumysql卸载

Step1.卸载MySQL

终端下依次输入以下命令卸载MySQL

<code>sudo apt-get autoremove --purge mysql-server-5.0sudo apt-get remove mysql-serversudo apt-get autoremove mysql-serversudo apt-get remove mysql-common(非常重要)sudo apt-get remove apparmor</code>
Copy after login

上面的其实有一些是多余的,建议还是按照顺序执行一遍

Step2.清理残留数据

<code>dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P</code>
Copy after login

###Step3.删除残余目录 sudo rm /var/lib/mysql/ -R sudo rm /etc/mysql/ -R

Step4.安装 mysql

<code>sudo apt-get install mysql-server mysql-clientsudo apt-get install php5-mysql 	//(安装php5-mysql 是将php和mysql连接起来 ) </code>
Copy after login

Step5.验证是否安装成功

一旦安装完成,MySQL 服务器应该自动启动。您可以在终端提示符后运行以下命令来检查 MySQL 服务器是否正在运行:

<code>netstat -tap | grep mysql</code>
Copy after login

当您运行该命令时,您可以看到类似下面的行:

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

如果服务器不能正常运行,您可以通过下列命令启动它:

<code>sudo /etc/init.d/mysql restart</code>
Copy after login

Step6.配置管理员密码

进入mysql命令行模式

<code>mysql -uroot -p 管理员密码</code>
Copy after login

配置 MySQL 的管理员密码

<code>mysqladmin -u root password newpassword</code>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!