LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 7413|回复: 5

如何启动Mysql(已解决)

[复制链接]
发表于 2008-11-15 14:33:16 | 显示全部楼层 |阅读模式
usage rc.mysqld start|stop|restart
Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysql/mysql.pid
081114 08:24:38  mysqld ended
发表于 2008-11-15 14:46:02 | 显示全部楼层
看看/var/lib/mysql/*.err, 报的什么错误.
你是否用mysql_install_db产生过系统表?
回复 支持 反对

使用道具 举报

发表于 2008-11-15 22:06:05 | 显示全部楼层
怎么不上网查啊?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-11-16 01:37:27 | 显示全部楼层
参考LinuxQuestion.org的帖子弄好了


bash-3.1# su mysql
bash-3.1# mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h Vecter password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
bash-3.1# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)
bash-3.1# cd /var/lib/mysql/
bash-3.1# ls
Vecter.err  ib_logfile0  ib_logfile1  ibdata1  mysql  test
bash-3.1# ls -al
total 20548
drwxr-x---  4 mysql mysql     4096 2008-11-16 08:54 .
drwxr-xr-x 19 root  root      4096 2008-11-16 00:23 ..
-rw-rw----  1 mysql root      8263 2008-11-16 08:44 Vecter.err
-rw-rw----  1 mysql mysql  5242880 2008-11-16 08:44 ib_logfile0
-rw-rw----  1 mysql mysql  5242880 2008-11-14 08:15 ib_logfile1
-rw-rw----  1 mysql mysql 10485760 2008-11-14 08:15 ibdata1
drwx------  2 root  root      4096 2008-11-16 08:54 mysql
drwx------  2 root  root      4096 2008-11-16 08:54 test
bash-3.1# chown -R mysql.mysql mysql
bash-3.1# ls
Vecter.err  ib_logfile0  ib_logfile1  ibdata1  mysql  test
bash-3.1# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)
bash-3.1# ls -al
total 20548
drwxr-x---  4 mysql mysql     4096 2008-11-16 08:54 .
drwxr-xr-x 19 root  root      4096 2008-11-16 00:23 ..
-rw-rw----  1 mysql root      8263 2008-11-16 08:44 Vecter.err
-rw-rw----  1 mysql mysql  5242880 2008-11-16 08:44 ib_logfile0
-rw-rw----  1 mysql mysql  5242880 2008-11-14 08:15 ib_logfile1
-rw-rw----  1 mysql mysql 10485760 2008-11-14 08:15 ibdata1
drwx------  2 mysql mysql     4096 2008-11-16 08:54 mysql
drwx------  2 root  root      4096 2008-11-16 08:54 test
bash-3.1# cd /etc/rc.d/
bash-3.1# ls
init.d                   rc.dnsmasq          rc.modules-2.6.24.5           rc.sysvinit
rc.0                   rc.font.new          rc.modules-2.6.24.5-smp  rc.udev
rc.4                   rc.fuse          rc.mysqld                   rc.wireless
rc.6                   rc.gpm          rc.nfsd                   rc.wireless.conf
rc.K                   rc.hald          rc.ntpd                   rc.yp
rc.M                   rc.httpd          rc.pcmcia                   rc0.d
rc.S                   rc.inet1          rc.rpc                   rc1.d
rc.acpid           rc.inet1.conf  rc.samba                   rc2.d
rc.alsa                   rc.inet2          rc.saslauthd                   rc3.d
rc.atalk           rc.inetd          rc.sendmail                   rc4.d
rc.bind                   rc.ip_forward  rc.serial                   rc5.d
rc.bluetooth           rc.local          rc.snmpd                   rc6.d
rc.bluetooth.conf  rc.messagebus  rc.sshd
rc.cups                   rc.modules          rc.syslog
bash-3.1# ls -al rc.m
rc.messagebus            rc.modules-2.6.24.5      rc.mysqld
rc.modules               rc.modules-2.6.24.5-smp  
bash-3.1# ls -al rc.mysqld
-rwxr-xr-x 1 root root 2585 2008-04-29 05:54 rc.mysqld
bash-3.1# ./rc.mysqld start
bash-3.1# nohup: redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql

bash-3.1# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51b Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
回复 支持 反对

使用道具 举报

发表于 2008-11-17 19:54:31 | 显示全部楼层
发现主要问题就是 /var/lib/mysql 下面文件的权限不是 mysql:mysql。只要改过来就好。
回复 支持 反对

使用道具 举报

发表于 2008-11-22 03:10:05 | 显示全部楼层
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

太经典的问题了,想想2002年初的时候我自己玩的时候,就被这个给弄得头大,到当时一个有名的论坛问几天也没人回应,当时就放弃了,不过从那以后,我很少去那个论坛。

有人只告诉我权限问题,没讲操作方法。(等我看到回帖时已经2005年了),

一直到2004年我玩slackware的时候,看到euler老兄整理的一篇 Slackware linux常见的46个问题帖子的时候。我才明白是怎么回事,应该怎么操作了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表