我在linux里装了mysql,但是netstat后没有看到3306端口打开,
网上说是没打开3306端口,要找到skip-networking这一行注释了,但在my.cnf中根本没有这一行.请高手帮想想办法,急等...

解决方案 »

  1.   

    你的mysqld 有没有运行啊? ps 看一下这个进程
      

  2.   

    USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
    root         1  0.0  0.0  3324  548 ?        S    08:25   0:00 init [5]         
    root         2  0.0  0.0     0    0 ?        SN   08:25   0:00 [ksoftirqd/0]
    root         3  0.0  0.0     0    0 ?        S<   08:25   0:00 [events/0]
    root         4  0.0  0.0     0    0 ?        S<   08:25   0:00 [khelper]
    root         5  0.0  0.0     0    0 ?        S<   08:25   0:00 [kacpid]
    root        14  0.0  0.0     0    0 ?        S<   08:25   0:00 [kblockd/0]
    root        15  0.0  0.0     0    0 ?        S    08:25   0:00 [khubd]
    root        32  0.0  0.0     0    0 ?        S    08:25   0:00 [pdflush]
    root        33  0.0  0.0     0    0 ?        S    08:25   0:00 [pdflush]
    root        34  0.0  0.0     0    0 ?        S    08:25   0:00 [kswapd0]
    root        35  0.0  0.0     0    0 ?        S<   08:25   0:00 [aio/0]
    root       181  0.0  0.0     0    0 ?        S    08:25   0:00 [kseriod]
    root       418  0.0  0.0     0    0 ?        S    08:25   0:00 [kjournald]
    root      1059  0.0  0.0     0    0 ?        S<   08:25   0:00 [kauditd]
    root      1682  0.0  0.0  1856  456 ?        S<s  08:25   0:00 udevd
    root      1932  0.0  0.0     0    0 ?        S<   08:25   0:00 [kmpathd/0]
    root      2017  0.0  0.0     0    0 ?        S    08:25   0:00 [kjournald]
    root      2551  0.0  0.0  2380  532 ?        Ss   08:26   0:00 syslogd -m 0
    root      2555  0.0  0.0  2608  380 ?        Ss   08:26   0:00 klogd -x
    rpc       2578  0.0  0.0  2484  548 ?        Ss   08:26   0:00 portmap
    rpcuser   2598  0.0  0.0  3572  712 ?        Ss   08:26   0:00 rpc.statd
    root      2627  0.0  0.0  4920  500 ?        Ss   08:26   0:00 rpc.idmapd
    root      2705  0.0  0.0  3136  464 ?        S    08:26   0:00 /usr/sbin/smartd
    root      2715  0.0  0.0  1636  424 ?        Ss   08:26   0:00 /usr/sbin/acpid
    root      2746  0.0  0.2 11200 3628 ?        Ss   08:26   0:00 cupsd
    root      2800  0.0  0.0  4596 1144 ?        Ss   08:26   0:00 /usr/sbin/sshd
    root      2815  0.0  0.0  2772  796 ?        Ss   08:26   0:00 xinetd -stayalive
    root      2834  0.0  0.1  8976 1952 ?        Ss   08:26   0:00 sendmail: accepti
    smmsp     2843  0.0  0.1  8056 1624 ?        Ss   08:26   0:00 sendmail: Queue r
    root      2854  0.0  0.0  2748  344 ?        Ss   08:26   0:00 gpm -m /dev/input
    htt       2885  0.0  0.0  1704  128 ?        Ss   08:26   0:00 /usr/sbin/htt -re
    htt       2886  0.0  0.1  8696 2928 ?        S    08:26   0:00 htt_server -nodae
    canna     2898  0.0  1.1 18972 17448 ?       Ss   08:26   0:00 /usr/sbin/cannase
    root      2910  0.0  0.0  5304  912 ?        Ss   08:26   0:00 crond
    xfs       2945  0.0  0.2  6224 3436 ?        Ss   08:26   0:00 xfs -droppriv -da
    root      2955  0.0  0.0  2080  484 ?        SNs  08:26   0:00 anacron -s
    root      2964  0.0  0.0  1928  424 ?        Ss   08:26   0:00 /usr/sbin/atd
    dbus      2983  0.0  0.0  3936  812 ?        Ss   08:26   0:00 dbus-daemon-1 --s
    root      2996  0.0  0.0  3600  904 ?        Ss   08:26   0:00 cups-config-daemo
    root      3007  0.0  0.1  5548 2428 ?        Ss   08:26   0:00 hald
    root      3094  0.0  0.0  3004  416 tty1     Ss+  08:26   0:00 /sbin/mingetty tt
    root      3137  0.0  0.0  2500  416 tty2     Ss+  08:26   0:00 /sbin/mingetty tt
    root      3184  0.0  0.0  3036  416 tty3     Ss+  08:26   0:00 /sbin/mingetty tt
    root      3230  0.0  0.0  1860  416 tty4     Ss+  08:26   0:00 /sbin/mingetty tt
    root      3268  0.0  0.0  2556  412 tty5     Ss+  08:26   0:00 /sbin/mingetty tt
    root      3309  0.0  0.0  3036  416 tty6     Ss+  08:26   0:00 /sbin/mingetty tt
    root      3349  0.0  0.1 11576 2316 ?        Ss   08:26   0:00 /usr/bin/gdm-bina
    root      3812  0.0  0.1 12216 2288 ?        S    08:26   0:00 /usr/bin/gdm-bina
    root      3841  0.0  0.5 11624 8392 ?        S    08:26   0:00 /usr/X11R6/bin/X 
    gdm       3994  0.0  0.8 59384 13724 ?       Ss   08:26   0:01 /usr/bin/gdmgreet
    root      3995  0.0  0.1  8244 2316 ?        Ss   08:27   0:00 sshd: root@notty 
    root      3997  0.0  0.0  4672 1228 ?        Ss   08:27   0:00 /usr/libexec/open
    root      4014  0.0  0.1  7400 2500 ?        Ss   08:27   0:00 sshd: root@pts/1 
    root      4016  0.0  0.0  5032 1376 pts/1    Ss   08:27   0:00 -bash
    root      4061  0.0  0.1  7988 2320 ?        Ss   08:42   0:00 sshd: root@notty 
    root      4063  0.0  0.0  4636 1220 ?        Ss   08:42   0:00 /usr/libexec/open
    root      4104  0.0  0.0  3216  764 pts/1    R+   08:55   0:00 ps -aux是不是mysql没有运行啊!
      

  3.   

    是的,用  service mysqld start 启一下试试。
      

  4.   


    启动后,看到mysql打开了,紧接着linux死机了...
    linux机有时候启动不起来...
      

  5.   

    检查错误日志。或者用 mysqld_safe 启一下试试。
      

  6.   

    ACMAIN_CHM大哥
    我启动mysql后,netstat仍然没有看到有3306端口
    Active Internet connections (w/o servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State      
    getnameinfo failed
    getnameinfo failed
    tcp        0     72 [UNKNOWN]:ssh               [UNKNOWN]:1324              ESTABLISHED 
    getnameinfo failed
    getnameinfo failed
    tcp        0      0 [UNKNOWN]:ssh               [UNKNOWN]:1305              ESTABLISHED 
    Active UNIX domain sockets (w/o servers)
    Proto RefCnt Flags       Type       State         I-Node Path
    unix  2      [ ]         DGRAM                    6651   @/var/run/hal/hotplug_socket
    unix  11     [ ]         DGRAM                    5543   /dev/log
    unix  2      [ ]         DGRAM                    3642   @udevd
    unix  2      [ ]         DGRAM                    9268   
    unix  3      [ ]         STREAM     CONNECTED     8857   
    unix  3      [ ]         STREAM     CONNECTED     8856   
    unix  3      [ ]         STREAM     CONNECTED     8855   
    unix  3      [ ]         STREAM     CONNECTED     8854   
    unix  3      [ ]         STREAM     CONNECTED     8772   /tmp/.X11-unix/X0
    unix  3      [ ]         STREAM     CONNECTED     8771   
    unix  3      [ ]         STREAM     CONNECTED     8770   /tmp/.X11-unix/X0
    unix  3      [ ]         STREAM     CONNECTED     8769   
    unix  3      [ ]         STREAM     CONNECTED     8753   /tmp/.font-unix/fs7100
    unix  3      [ ]         STREAM     CONNECTED     8752   
    unix  3      [ ]         STREAM     CONNECTED     8757   /tmp/.X11-unix/X0
    unix  3      [ ]         STREAM     CONNECTED     8669   
    unix  2      [ ]         DGRAM                    7625   
    unix  3      [ ]         STREAM     CONNECTED     6650   /var/run/dbus/system_bus_socket
    unix  3      [ ]         STREAM     CONNECTED     6649   
    unix  3      [ ]         STREAM     CONNECTED     6524   /var/run/dbus/system_bus_socket
    unix  3      [ ]         STREAM     CONNECTED     6523   
    unix  3      [ ]         STREAM     CONNECTED     6500   
    unix  3      [ ]         STREAM     CONNECTED     6499   
    unix  2      [ ]         DGRAM                    6440   
    unix  2      [ ]         DGRAM                    6345   
    unix  2      [ ]         DGRAM                    6252   
    unix  2      [ ]         DGRAM                    6236   
    unix  2      [ ]         DGRAM                    6215   
    unix  2      [ ]         DGRAM                    6158   
    unix  3      [ ]         STREAM     CONNECTED     5728   
    unix  3      [ ]         STREAM     CONNECTED     5727   
    unix  2      [ ]         DGRAM                    5612   
    unix  2      [ ]         DGRAM                    5551   
      

  7.   

    先确认你的mysqld 已经启来了。[code=BatchFile][root@xx ~]# ps -aux | grep mysqld
    Bad syntax, perhaps a bogus '-'?
    root     19721  0.0  0.1  4236 1232 ?        S    Apr10   0:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf
    mysql    19748  0.0  1.7 123412 18244 ?      S    Apr10   0:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock
    root     10583  0.0  0.0  2892  464 pts/1    S    21:17   0:00 grep mysqld
    [root@xx ~]#[/code]
      

  8.   

    我这边ps -aux | grep mysqld-bash: [root@localhost: command not found
    [root@localhost ~]# Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
    l/mysql5.0.45/bin/mysqld_safe --user=root
    -bash: Warning:: command not found
    [root@localhost ~]# root      4072  0.0  0.0  6008 1068 pts/1    S    06:08   0:00 /bin/sh /usr/local/mysql5.0.45/bin/mysqld_safe --user=root
    -bash: root: command not found
    [root@localhost ~]# root      4098  0.0  0.8 109060 12524 pts/1  Sl   06:08   0:00 /usr/local/mysql5.0.45/libexec/mysqld --basedir=/usr/local/mysql5.0.45 --datadir=/usr/local/mysql5.0.45/var --user=root --pid-file=/usr/local/mysql5.0.45/var/localhost.localdomain.pid --skip-external-locking --port=3306 --socket=/tmp/mysql.sock
    -bash: root: command not found
    [root@localhost ~]# root      4189  0.0  0.0  4708  636 pts/1    R+   06:18   0:00 grep mysqld
      

  9.   

    [root@localhost ~]# service mysqld start
    鍚姩 MySQL锛?[  纭畾  ]
    [root@localhost ~]# ps -aux | grep mysqld 
    Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
    root      4058  0.0  0.0  5616 1228 pts/1    S    06:32   0:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid
    mysql     4086  0.4  1.0 117312 16984 pts/1  Sl   06:32   0:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
    root      4104  0.0  0.0  4412  644 pts/1    S+   06:33   0:00 grep mysqld
      

  10.   

    楼主啊,看来你要先学习一下linux的操作。下面黑体部分是命令,需要你输入后按回车。[root@xx ~]# ps -aux | grep mysqld
      

  11.   


    [root@localhost ~]# ps -aux | grep mysqld
    Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
    root      4058  0.0  0.0  5616 1228 pts/1    S    06:32   0:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid
    mysql     4086  0.0  1.1 117336 17168 pts/1  Sl   06:32   0:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
    root      4111  0.0  0.0  4124  636 pts/1    R+   06:38   0:00 grep mysqld
      

  12.   


    上面是我启动mysql服务后,输入ps -aux | grep mysqld后按回车出来的结果
      

  13.   

    应该已经好了,你看不到3306是因为你现在还没有联接,用这个命令选项。
    netstat -an | grep 3306现在你可以直接 [root@wuxsx008 ~]# mysql -uroot 
    联接你的mysql 了建议先看一下官方文档中的教程。
    MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  14.   

    现在可以可以看到3306端口了,多谢ACMAIN_CHM大牛啊[root@localhost ~]# netstat -an
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State      
    tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      
    tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
    tcp        0      0 0.0.0.0:113                 0.0.0.0:*                   LISTEN      
    tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      
    tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
    tcp        0      0 0.0.0.0:669                 0.0.0.0:*                   LISTEN      
    tcp        0      0 192.168.1.153:3306          192.168.1.179:1092          ESTABLISHED 
    tcp        0      0 :::22                       :::*                        LISTEN      
    tcp        0      0 ::ffff:192.168.1.153:22     ::ffff:192.168.1.179:3335   ESTABLISHED 
    tcp        0      0 ::ffff:192.168.1.153:22     ::ffff:192.168.1.179:2695   ESTABLISHED 
    udp        0      0 0.0.0.0:663                 0.0.0.0:*                               
    udp        0      0 0.0.0.0:666                 0.0.0.0:*                               
    udp        0      0 0.0.0.0:111                 0.0.0.0:*                               
    udp        0      0 0.0.0.0:631                 0.0.0.0:*                               
    Active UNIX domain sockets (servers and established)
    Proto RefCnt Flags       Type       State         I-Node Path
    unix  2      [ ACC ]     STREAM     LISTENING     6268   /dev/gpmctl
    unix  2      [ ]         DGRAM                    7856   @/var/run/hal/hotplug_socket
    unix  2      [ ACC ]     STREAM     LISTENING     5882   /var/run/acpid.socket
    unix  2      [ ACC ]     STREAM     LISTENING     6329   /var/run/.iroha_unix/IROHA
    unix  2      [ ACC ]     STREAM     LISTENING     6331   /var/run/iiim/.iiimp-unix/9010
    unix  2      [ ACC ]     STREAM     LISTENING     6512   /var/run/dbus/system_bus_socket
    unix  2      [ ]         DGRAM                    3640   @udevd
    unix  11     [ ]         DGRAM                    5558   /dev/log
    unix  2      [ ACC ]     STREAM     LISTENING     6439   /tmp/.font-unix/fs7100
    unix  2      [ ACC ]     STREAM     LISTENING     8271   /tmp/.gdm_socket
    unix  2      [ ACC ]     STREAM     LISTENING     8387   /tmp/.X11-unix/X0
    unix  2      [ ACC ]     STREAM     LISTENING     8764   /tmp/ssh-wulLuA3991/agent.3991
    unix  2      [ ACC ]     STREAM     LISTENING     8866   /tmp/mysql.sock
    unix  2      [ ]         DGRAM                    16202  
    unix  3      [ ]         STREAM     CONNECTED     10932  /var/run/dbus/system_bus_socket
    unix  3      [ ]         STREAM     CONNECTED     10931  
    unix  3      [ ]         STREAM     CONNECTED     9139   
    unix  3      [ ]         STREAM     CONNECTED     9138   
    unix  3      [ ]         STREAM     CONNECTED     9137   
    unix  3      [ ]         STREAM     CONNECTED     9136   
    unix  3      [ ]         STREAM     CONNECTED     8727   /tmp/.X11-unix/X0
    unix  3      [ ]         STREAM     CONNECTED     8726   
    unix  3      [ ]         STREAM     CONNECTED     8725   /tmp/.X11-unix/X0
    unix  3      [ ]         STREAM     CONNECTED     8724   
    unix  3      [ ]         STREAM     CONNECTED     8708   /tmp/.font-unix/fs7100
    unix  3      [ ]         STREAM     CONNECTED     8707   
    unix  3      [ ]         STREAM     CONNECTED     8712   /tmp/.X11-unix/X0
    unix  3      [ ]         STREAM     CONNECTED     8427   
    unix  2      [ ]         DGRAM                    8120   
    unix  3      [ ]         STREAM     CONNECTED     7855   /var/run/dbus/system_bus_socket
    unix  3      [ ]         STREAM     CONNECTED     7854   
    unix  3      [ ]         STREAM     CONNECTED     6539   /var/run/dbus/system_bus_socket
    unix  3      [ ]         STREAM     CONNECTED     6538   
    unix  3      [ ]         STREAM     CONNECTED     6515   
    unix  3      [ ]         STREAM     CONNECTED     6514   
    unix  2      [ ]         DGRAM                    6455   
    unix  2      [ ]         DGRAM                    6360   
    unix  2      [ ]         DGRAM                    6267   
    unix  2      [ ]         DGRAM                    6251   
    unix  2      [ ]         DGRAM                    6230   
    unix  2      [ ]         DGRAM                    6173   
    unix  3      [ ]         STREAM     CONNECTED     5743   
    unix  3      [ ]         STREAM     CONNECTED     5742   
    unix  2      [ ]         DGRAM                    5627   
    unix  2      [ ]         DGRAM                    5566