ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
今天执行mysql操作的时候出现了错误:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'问题
1:首先检查是否安装了mysql-server了
sudo apt-get install mysql-server to install mysql on ubuntu, 如果mysql-server已经存在了,那么在去尝试一下是否成功,如果还是这个错误的话那么就是文件/var/run/mysqld/mysqld.sock 不存在。
2:如果/var/run/mysqld/mysqld.sock文件不存在应该怎么办?
执行 vim /etc/mysql/my.cnf
将会看到内容如下:
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
你的mysql的配置在/etc/mysql/mysql.conf.d目录下的mysqld.cnf文件,打开如下:
可以看到:bind-address = 127.0.0.1 socket = /var/run/mysqld/mysqld.sock 等信息
我的虚拟机是/var/run下面没有mysqld目录,执行下面命令,然后目录和sock文件就都有了
sudo mkdir -p /var/run/mysqld
sudo chown mysql /var/run/mysqld/
sudo service mysql restart
现在就都有了:
然后执行:mysql -u root -p 然后提示你输入密码,即可, 如下图所示:
就可以了
---------------------
作者:mellymengyan
来源:CSDN
原文:https://blog.csdn.net/mellymengyan/article/details/78958486
版权声明:本文为博主原创文章,转载请附上博文链接!
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'的更多相关文章
- mysql之ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决方法
LAMPP安装完成之后,mysql -u root -p连不上,报这个错误: ERROR 2002 (HY000): Can't connect to local MySQL server throu ...
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)-mysql.sock丢失解决方案
我们的LAMP是搭建在UBUNTU 12.04 LTS上的. LAMP是通过编译的方式进来安装的. 在一次处理意外挂机时由于未知的原因在重启后发现无法连接数据库了, 在打开网站时出现如下的的提示: E ...
- Running MYSQL 5.7 By Bash On Ubuntu On Windows:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@PC-RENGUOQIANG:/usr/sbin# /etc/init.d/mysql start * Starting MySQL database server mysqld [ OK ...
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决
用XAMPP装装好mysql之后,mysql -uroot 连不上,报这个错误: ERROR 2002 (HY000): Can't connect to local MySQL server t ...
- ubuntu 下安装 mysql 启动报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
环境: ubuntu LTS 18.04.1 mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) 初探 linux,按照如下安装完mysql sudo ...
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
今天服务器遇到了一个很熟悉的问题, 输入 #mysql -u root -p ERROR 2002 (HY000):Can't connect to local MySQL server ...
- 解决mysql登陆时出现“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)”
mariadb同样适用 首先检查mysql状态 linux-6yo1:~ # /etc/init.d/mysql status Checking for service MySQL: unused m ...
- 解决Mysql错误:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
需要重启服务器:sudo /etc/init.d/mysql restart
- mysql出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 错误
init 神奇..其他的都没有成功,这个居然成功了!! 还试验过:sudo mysqld restart啥的,都没有用......
随机推荐
- gradle上sourceSets配置&同名文件合并问题
gradle的sourceSets可以对不同的buildType, productFlavor,buildVariant设置不同的文件路径,进行多样化处理. sourceSets{ main{ man ...
- Batchsize与learning rate
https://www.zhihu.com/question/64134994 1.增加batch size会使得梯度更准确,但也会导致variance变小,可能会使模型陷入局部最优: 2.因此增大b ...
- RestTemplate 超级严重BUG之 restTemplate.getForEntity对于下载文件的地址请求 header不起作用
错误下载:RestTemplate restTemplate=new RestTemplate();HttpHeaders httpHeaders=new HttpHeaders();httpHead ...
- <转>ThinkPHP的开发常用系统配置项
/* 项目设定 */ ’APP_DEBUG’ => false, // 是否开启调试模式 ’APP_DOMAIN_DEPLOY’ => false, // 是否使用独立域名部署项目 ’AP ...
- rsync服务实践
RSYNC数据备份 RSYNC=Remote Sync 远程同步 高效,一定要结合shell 官方网站:https://rsync.samba.org/ Author: Andrew Tr ...
- Git回滚到指定的commit
查看历史commint $ git log (可以记下sha码) 回退命令: $ git reset --hard HEAD^ 回退到上个版本$ git reset --hard HEAD~3 回退到 ...
- 字符编码 python2与python3的区别
目录 1. 字符编码 2. 文本编辑器存储信息的过程 3. 编码: 1. 编码的历史 2. gb2312和gbk的区别 3. 编码和解码 4. python解释器 解释代码的流程 1. 读取文本到解释 ...
- 查看jar包内容
查看jar包内容 查看jar包内容的基本命令: jar tf jar-file 参数解释: The t option indicates that you want to view the table ...
- 如何编译Java程序以及运行程序
一.编辑运行 二.HelloWorld程序的组成: 三.public static void main(String[] args){} 四.System.out.println("Hell ...
- vue中的:is
is string | Object (组件的选项对象) <div id="app"> <span>这是:is的案例</span> <co ...