无需 sudo 即可连接到本地 MySQL 服务器 [英] Connect to local MySQL server without sudo
问题描述
这个命令:
mysql -uroot -p
出现以下错误:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
但是使用 sudo 权限运行相同的工作:
But running the same with sudo privileges, works:
sudo mysql -uroot -p
我的MySQL Server安装是自定义的,因为我需要5.1版本,所以我从官网下载了RPM,用alien转换成deb,用dpkg安装.名为:/var/lib/mysql/mysql.sock 的文件存在,但它的所有者是 mysql 用户.
My MySQL Server installation is a custom one, as i needed the 5.1 version, so i downloaded the RPM from the official website, converted it to deb using alien, and installed it with dpkg. The file named: /var/lib/mysql/mysql.sock exists, but it's owner is the mysql user.
请问,我怎样才能摆脱 sudo 要求?
Ubuntu 14.04MySQL 服务器 5.1.73MySQL 客户端 5.5.37
Ubuntu 14.04 MySQL Server 5.1.73 MySQL Client 5.5.37
推荐答案
您需要更改/var/lib/mysql/和 sock 文件的权限,以使其可以被 root 以外的其他用户读取.你可以试试这个:
You need to change the permissions to /var/lib/mysql/ and the sock file to let it be readable by other users than root. You can try this one:
sudo chmod -R 755/var/lib/mysql/
这篇关于无需 sudo 即可连接到本地 MySQL 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!