MYSQL没有在Ubuntu OS上运行 - 错误2002

时间:2011-01-09 07:40:24

标签: mysql database-connection ubuntu-10.04

我是mysql DB的新手。我试图在Ubuntu 10.04上运行MYSQL服务器。通过Synaptic Package Manager我安装了mysql版本:mysql-client-5.1

我想知道我是如何通过上面的方式为我安装的mysql-client软件设置数据库密码。如果你能在这方面给我启发,那就太好了。

当我尝试运行此数据库时,遇到下面给出的错误:

mohnish@mohnish-laptop:/var/lib$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
mohnish@mohnish-laptop:/var/lib$ 

我提到了另一位用户发布的similar question。我没有通过提议的答案找到解决方案。

例如,当我尝试针对类似问题发布的解决方案时,我得到了以下内容:

mohnish@mohnish-laptop:/var/lib$ service start mysqld
start: unrecognized service
mohnish@mohnish-laptop:/var/lib$ ps -u mysql
ERROR: User name does not exist.
********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real group ID (supports names)
-a all w/ tty except session leaders  -U by real user ID (supports names)
-d all except session leaders         -g by session OR by effective group name
-e all processes                      -p by process ID
T  all processes on this terminal     -s processes in the sessions given
a  all w/ tty, including other users  -t by tty
g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
r  only running processes             U  processes for specified users
x  processes w/o controlling ttys     t  by tty
*********** output format **********  *********** long options ***********
-o,o user-defined  -f full            --Group --User --pid --cols --ppid
-j,j job control   s  signal          --group --user --sid --rows --info
-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
-l,l long          u  user-oriented   --sort --tty --forest --version
-F   extra full    X  registers       --heading --no-heading --context
                    ********* misc options *********
-V,V  show version      L  list format codes  f  ASCII art forest
-m,m,-L,-T,H  threads   S  children in sum    -y change -l format
-M,Z  security data     c  true command name  -c scheduling class
-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy
mohnish@mohnish-laptop:/var/lib$ which mysql
/usr/bin/mysql
mohnish@mohnish-laptop:/var/lib$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

我甚至尝试过引用http://forums.mysql.com/read.php?11,27769,84713#msg-84713但找不到任何有用的东西。

请告诉我如何解决此错误。

非常感谢..

3 个答案:

答案 0 :(得分:2)

mohnish@mohnish-laptop:/var/lib$ service mysqld start 

看起来你没有安装mysql服务器包

  

sudo apt-get install mysql-server

应该帮助

答案 1 :(得分:2)

这真的属于serverfault。

无论如何,你安装了mysql-client软件包,但你需要的是mysql-server软件包。客户端只是命令行客户端,而服务器则运行服务器本身。

在Ubuntu上安装后,您可以通过以下方式以root身份启动和停止它:

/etc/init.d/mysql start
/etc/init.d/mysql stop

答案 2 :(得分:0)

使用以下命令

dpkg -l mysql* | grep ii | awk '{ print $2 }' | sudo xargs apt-get remove --purge -y 

&安培;&安培;

sudo apt-get install mysql-server