Home >Database >Mysql Tutorial >ubuntu下mysql的ERROR 2002_MySQL

ubuntu下mysql的ERROR 2002_MySQL

WBOY
WBOYOriginal
2016-06-01 13:12:181220browse

Ubuntu

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

在网上查资料,捣鼓了个把小时,无奈之下,只得重装,重装的话,mysql必须卸载干净,否者问题依然没有解决。

mysql在ubuntu下的完全卸载:

删除 mysql
1 sudo apt-get autoremove --purge mysql-server-5.0
2 sudo apt-get remove mysql-server
3 sudo apt-get autoremove mysql-server
4 sudo apt-get remove mysql-common (非常重要)
清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P


重新安装mysql:

1 sudo apt-get install mysql-server
2 sudo apt-get install mysql-client


一旦安装完成,MySQL 服务器应该自动启动。您可以在终端提示符后运行以下命令来检查 MySQL 服务器是否正在运行:
 sudo netstat -tap | grep mysql
当您运行该命令时,您可以看到类似下面的行:
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
如果服务器不能正常运行,您可以通过下列命令启动它:
1 sudo /etc/init.d/mysql restart


3、进入mysql
$mysql -uroot -p 管理员密码
配置 MySQL 的管理员密码:
sudo mysqladmin -u root password newpassword


Statement:
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