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>


猜你喜欢
- 一、增强的可扩展性 Oracle9i Real Application Clusters是Oracle的下一代并行服务器系列产品。Oracl
- 前言网络摄像头的视频流解析直接使用通过http的Mjpeg是具有边界帧信息的multipart / x-mixed-replace,而jpe
- 多表查询使用单个select 语句从多个表格中取出相关的查询结果,多表连接通常是建立在有相互关系的父子表上;1交叉连接第一个表格的所有行 乘
- 内容摘要:asp使用最多的就是ACCESS数据库和ms sql server数据库,本文列出了asp连接这两个数据库的方
- 准备正常情况下,创建class的实例后,可以给该实例绑定任何属性和方法,这就是动态语言的灵活性。首先定义一个classclass A(obj
- parseFloat()方法的定义和用法:parseFloat()方法可以解析一个字符串,并返回一个浮点数。注:如果字符串中的第一个字符不能
- 前言在MySQL中,我们可以通过EXPLAIN命令获取MySQL如何执行SELECT语句的信息,包括在SELECT语句执行过程中表如何连接和
- 使用命令行登录MySQL报错1045 Access denied for user ‘root’@&
- python数组进行降维在深度学习训练过程中,我们有时候想要输出图片看看图片长什么样,但是训练时的图片格式一般都会多出一个批次的维度,如[1
- 前言:c3p0 是一个开源的数据库连接池,实现了 JDBC 3 规范;本文主要介绍 c3p0 的基本使用,文中使用到的软件版本:Java 1
- 加密接口怎么测试?(1)写个函数或者方法,把要加密的参数使用这个函数过滤一遍,等于就是说把数据丢进去,加密了之后,再通过这个加密好的数据传输
- 1、问题:群中有同学贴了如下一段代码,问为何 list 最后打印的是空值? from multiprocessing
- 这篇文章主要介绍了python线程定时器Timer实现原理解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,
- 问题你要处理由大量不同类型的对象组成的复杂数据结构,每一个对象都需要需要进行不同的处理。比如,遍历一个树形结构,然后根据每个节点的相应状态执
- 问题描述我在flask程序中,启动了另一个python程序-test.py:os.system('nohup python /opt
- 一、如果是刚刚删除,那么有两方法:首先用show parameter undo;命令查看当时的数据库参数undo_retention设置。显
- table估计每个跟web打过交道的人都会经常接触到,跟js结合能做出很多不错的体验。这里打算结合js做一个系列,包括一些操作和效果,虽然现
- mycliMyCLI is a command line interface for MySQL, MariaDB, and Percona
- 利用原生js实现一个简易的计算器(附详细注释),供大家参考,具体内容如下<!DOCTYPE html><html lang
- 一、准备训练数据主要的数据有两个:1.小黄鸡的聊天语料:噪声很大2.微博的标题和评论:质量相对较高二、数据的处理和保存由于数据中存到大量的噪