ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)已解决
程序员文章站
2024-01-30 20:08:28
说明mysql版本: 8.0.20系统: deepin问题描述安装、配置好mysql后时可以正常操作数据库的,但当我重启电脑后,会报以下错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)猜测是因为没有开启mysql服务的原因,就像windows中配置好数据库后,要在设置中开始mysql服务,否则就无法登录。所以尝试开启mysql服务sudo my....
说明
mysql版本: 8.0.20
系统: deepin
问题描述
安装、配置好mysql后是可以正常操作数据库的,但当我重启电脑后,再次登录时会报以下错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
猜测是因为没有开启mysql服务的原因,就像windows中配置好数据库后,要在设置中开始mysql服务,否则就无法登录。
所以尝试开启mysql服务
sudo mysql/support-files/mysql.server start
此处mysql是配置了环境变量的,若没有,则需在mysql安装目录下运行以下命令
sudo ./support-files/mysql.server start
此时,我们再登录mysql,就可以了。
但每次登录都要执行该命令,比较麻烦。所以我们配置mysql.server
的开机自启动。
- 复制该文件到etc目录下
sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
- 创建
rc.local
文件sudo vim /etc/rc.local
- 在文件中添加以下内容
#!/bin/bash # rc.local config file created by use service mysqld start exit 0
- 添加可执行权限
sudo chmod +x /etc/rc.local
本文地址:https://blog.csdn.net/qq_43366662/article/details/107316535
推荐阅读
-
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)已解决
-
Linux登录MySQL时出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock'解决方法
-
MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket_MySQL
-
Linux登录MySQL时出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock'解决方法
-
MySQL错误 ERROR 2002 (HY000): Can't connect to local MySQL server through socket 的解决办法
-
linux安装MySQL后输入mysql显示 ERROR 2002 (HY000): Can't connect to local MySQL server through socket
-
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mys
-
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mys
-
mac下安装mysql报Can't connect to local MySQL server through socket '/tmp/mysql.sock' brew
-
提示:Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)