mysql服务启动却连接不上的解决方法
作者:CyanSkye 发布时间:2024-01-24 23:45:13
标签:mysql,服务启动,连接
mysql服务启动,但是连接不上,如何解决?
登陆报错:
root@localhost:~# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
root@localhost:~# service mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL. [ OK ]
root@localhost:~# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
分析原因:
原因不详,知道了补上
解决方案一:
root@localhost:~# find / -name mysql.sock
/tmp/mysql.sock
root@localhost:~# mysql -u root -p -S /tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.15-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
解决方案二:
root@localhost:~# find / -name mysql.sock
/tmp/mysql.sock
root@localhost:~# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
# 加上下面的这段代码即可
[mysql]
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
root@localhost:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.15-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
0
投稿
猜你喜欢
- 思路:队列使用说明:multiprocessing.Queue()#用于进程间通信,单主进程与子进程无法通信(使用进程池时尽量不要使用这个)
- 可视化单词统计词频统计中文分词项目架构新建一个文件,输入文件的内容,查询此文件中关键字的出现的次数,关键字出现的位置,将所有的文本按照中文分
- 前两天写了一篇《浅谈网站用户粘性的含义》的文章,有些个别网友问可否谈谈怎么样加强用户粘性的问题?虽然对此本人没有系统的理论做以支撑,但是既然
- python安装完成后,直接运行python.exe能够正常执行python程序。但是进入到cmd命令窗口(同时按下win+r组合键后输入c
- 前言:前面的一章我们展示了选择结构的三种基本形式,并给出了实例演示,但是大家在编写代码过程中仍然要注意一些细节,尤其是代码块的缩进,这对if
- 自己写的方法,适用于linux,#!/usr/bin/python#coding=utf-8import sysimport os, os.
- 1.首先,我们需要过滤所有客户端提交的内容,其中包括?id=N一类,另外还有提交的html代码中的操作数据库的select及asp文件操作语
- 本文实例讲述了RSA实现JS前端加密与PHP后端解密功能。分享给大家供大家参考,具体如下:web前端,用户注册与登录,不能直接以明文形式提交
- 在爬一个网站的时候,端点包含中文浏览器是可以自动解决这个转换的,在代码中就需要处理一下了。请求过程的异常如下:self._output(re
- python-opencv获取二值图像轮廓及中心点坐标代码:groundtruth = cv2.imread(groundtruth_pat
- itchat是一个开源的微信个人号接口,使用python调用微信从未如此简单。使用不到三十行的代码,你就可以完成一个能够处理所有信息的微信机
- 起因:学校运河杯报了个项目,制作一个天气预测的装置。我用arduino跑了BME280模块,用蓝牙模块实现两块arduino主从机透传。但是
- 许多人也许会注意到一个现象,那就是在一些现代编程语言(当然,并不是指“最近出现”的编程语言)中,自增
- 代码如下:Class template Private c_Char, c_Path, c
- 一、旧版本(1.0以下)的卷积函数:tf.nn.conv2d在tf1.0中,对卷积层重新进行了封装,比原来版本的卷积层有了很大的简化。con
- 一、简介 Python的条件和循环语句,决定了程序的控制流程,体现结构的多样性。
- 开启xp_cmdshell: exec sp_configure 'show advance
- 学习如何使用 Python 的 Pygame 模块编程电脑游戏,并开始操作引力。真实的世界充满了运动和生活。物理学使得真实的生活如此忙碌和动
- 昨天在书友会上讨论信息分类和方法,有位朋友问:“大家现在讨论的还是几年前那套web2.0的东西,有没有一些新的东西可以分享?”我当时确实感觉
- user-define-session-inc.php文件代码:<?php function mysession_open($save