mysql -Can‘t connect to local MySQL server through socket

来源:百度文库 编辑:神马文学网 时间:2024/04/28 18:24:03
[root@freebsd ~]# /usr/local/etc/rc.d/mysql-server start
[root@freebsd ~]# mysql
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
学习Freebsd过程中的一些小技巧
作者:未知 时间:2005-09-13 22:50 出处:Blog.ChinaUnix.net 责编:My FAQ
摘要:学习Freebsd过程中的一些小技巧
mysql 起动错误解决办法- -
Access denied for user‘‘@‘localhost‘ to database ‘mysql‘
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
第一次安装运行以下一句,产生数据库文件
/usr/local/bin/mysql_install_db
chown -R mysql /var/db/mysql
启动mysql
/usr/local/bin/mysqld_safe &
mysql 起动错误解决办法- -
Access denied for user‘‘@‘localhost‘ to database ‘mysql‘
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
第一次安装运行以下一句,产生数据库文件
/usr/local/bin/mysql_install_db
chown -R mysql /var/db/mysql
启动mysql
/usr/local/bin/mysqld_safe &
=====================================
apache启动
# /usr/local/sbin/apachectl start
可以在任何时候使用下面的命令来停止服务:
# /usr/local/sbin/apachectl stop
当由于某种原因修改了配置文件之后, 需要重启服务器:
# /usr/local/sbin/apachectl restart
========================================
请问你装的是什么版本?如果是5.4的话,ssh默认是不打开的。需要在/etc/rc.conf里面添加sshd_enable="YES"才行的。用SecureCRT 4.1登陆时设置Primary的时候设为keyboard就行了。5.4的验证方式不能用password[/img]
确认/etc/ssh/sshd_config里面下列三行前无#
Port 22
Protocol 2
PasswordAuthentication yes
=======================================
前几天有个帖子有说如何不重启动而使网络参数修改生效的方法。
/etc/netstart restart
================================================
最简单的用系统自带的ftpd
vi /etc/inetd.conf
把 ftpd前的#去掉存盘退出。(ipv6你应该用不上第二个ftpd的#你就不用去了)
如果你系统里原先没有启动inetd的话
就用#inetd启动守护进程inetd
如果你已经启动过了inetd就用 #killall -HUP inetd 从启动inetd
给他们一个帐号就可以连上你的机器了,更具体的man ftpd。
如果要inetd在下次随系统启动编辑/etc/rc.conf加入inetd_enable="YES"
如果你原先有了就不用再加了。
当然ports里还提供丰富的ftpd 比如vsftpd pureftpd,配置都不麻烦。
=============================================================
如果您知道一个port的准确名字, 但需要知道在哪个类别里面能找到它
例如:
# whereis lsof
lsof: /usr/ports/sysutils/lsof
还有另外的一个寻找您需要的port的方法--是用ports collecton 内嵌的搜索机制。要使用这个搜索, 您需要先到 /usr/ports目录下面。在那个目录里面, 运行make search name=program-name, program-name 就是您想寻找的程序名字。 举个例子,如果您想找 lsof:
# cd /usr/ports
# make search name=lsof
Port:   lsof-4.56.4
Path:   /usr/ports/sysutils/lsof
Info:   Lists information about open files (similar to fstat(1))
Maint: obrien@FreeBSD.org
Index:  sysutils
B-deps:
R-deps:
================================================================
ports安装软件
定位到软件ports目录
make install clean
指定安装目录
# make PREFIX=/usr/home/example/local install
卸载
make deinstall
============================
查找文件
find / -name *tbz
==============================
将pkg_add -r 的下载地址改成ftp://ftp.freebsdchina.org
bash shell
#export PACKAGEROOT="ftp://ftp.freebsdchina.org"
csh shell
#setenv PACKAGEROOT "ftp://ftp.freebsdchina.org"
===========================
在/etc/make.conf里设置ports用的FTP服务器设置好几个
ee /etc/make.conf
add
MASTER_SITE_OVERRIDE=ftp://ftp3.jp.freebsd.org/pub/FreeBSD/ports/distfiles/$
http://www.myfaq.com.cn/2005September/2005-09-13/202434.html
 Can‘t connect to local MySQL server through socket 问题解决    
Fedora8启动mysql 报错:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.
另外看看是不是权限问题.
2、确定你的mysql.sock是不是在那个位置,
mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock
3、试试:service mysqld start
4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start
启动 MySQL: [ 确定 ]
[root@localhost ~]# mysql -uroot -p
ERROR 2002 (HY000): Can‘t connect to localMySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)
原因是,/var/lib/mysql 的访问权限问题。
shell> chown -R mysql:mysql /var/lib/mysql
接着启动服务器
shell> /etc/init.d/mysql start
服务器正常启动后察看 /var/lib/mysql 自动生成mysql.sock文件。
但是我的问题仍然没有得到解决。
问题终于解决:
方法:    修改/etc/my.conf:
[mysqld]
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
[mysql.server]
user=mysql
basedir=/usr/local/mysql
If there is not currently a section called [client], add one at the bottom of the file and copy the socket= line under the [mysqld] section such as:
[client]
socket=/var/lib/mysql/mysql.sock
发现依旧如此,运行/etc/init.d/mysql start报错:    Starting MySQLCouldn‘t find MySQL manager or server
是mysqld服务没启,运行/usr/local/mysql/bin/mysqld_safe &
问题解决。
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2039988
2006-11-27 11:06 banyao
FB6.2rc1下MYsQL启动出错(已解决)
[code]
root@yao[/usr/ports/databases/mysql51-server]# make install
===>  mysql-server-5.1.11 cannot install: MySQL versions mismatch: mysql50-client is installed and wanted version is mysql51-client.
*** Error code 1
Stop in /usr/ports/databases/mysql51-server.
root@yao[/usr/ports/databases/mysql51-server]#
root@yao[/usr/ports/databases/mysql50-server]# make install
root@yao[/usr/ports/databases/mysql50-server]# /usr/local/etc/rc.d/mysql-server start
Starting mysql.
root@yao[/usr/ports/databases/mysql50-server]#
root@yao[/usr/local/etc]# mysql
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
root@yao[/usr/local/etc]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
root@yao[/usr/local/etc]# find /usr -name my.cnf
root@yao[/usr/local/etc]#
[/code]
这个是在另外一台机器上遇到的问题
[code]
phpMyAdmin - Error
phpMyAdmin是在官方网上下载的最新版本2.9.1.1
cp phpMyadmin /usr/local/www/apache/data
目录下有一个config.sample.inc.php文件,找把到教程中说的config.inc.php  而且里面的内容也不想是config.inc.php
firefox http://localhost/phpadmin
浏览器中显示:
Fatal error: Call to undefined function preg_replace() in /usr/local/www/apache22/data/phpMyAdmin/libraries/sanitizing.lib.php on line 37
[/code]
[[i] 本帖最后由 大大狗 于 2006-11-27 14:49 编辑 [/i]]
2006-11-27 11:15 大大狗
可能是mysql.sock的权限不够
2006-11-27 11:19 大大狗
mysql.sock 它是被放在 /tmp/mysql.sock 临时文件夹下的,所你可以重新启动一下系统就可以了
reboot     在   mysql -u root -p
2006-11-27 11:21 大大狗
第二个问题
解决方法    [code]出现无法识别preg_replace函数的错误需要安装pcre , 位于 /usr/ports/devel/php5-pcre
正则表达式的支持是由 PCRE(Perl Compatible Regular Expression)库提供的,这是个开放源代码的软件,作者为 Philip Hazel,版权属于英国剑桥大学。可于以下地址获得:ftp://ftp.csx.cam.ac.uk/
[/code]
2006-11-27 13:57 banyao
谢谢,第一个问题解决拉,第二个问题,依然是不行,
是不是phpMyAdmin缺少了个config.inc.php配置问题?
php5-extensions已经ports上去了阿
phpMyAdmin - Error
Cannot load session extension. Please check your PHP configuration.
2006-11-27 14:01 大大狗
/usr/ports/devel/[color=Blue]php5-pcre[/color]  这个已经ports了吗
2006-11-27 14:13 banyao
[quote]原帖由 [i]大大狗[/i] 于 2006-11-27 14:01 发表
/usr/ports/devel/[color=Blue]php5-pcre[/color]  这个已经ports了吗 [/quote]
已经ports上了,
2006-11-27 14:22 banyao
重启系统之后就可以了,谢谢 大大狗版主
奇怪怎么我重启服务不行,非得要重启系统才可以
http://bbs2.chinaunix.net/archiver/tid-861670.html
作者 留言
mylcx1028
半仙
注册时间: 2007-05-17
文章: 1
发表于: Thu 2007-05-17 15:07:32    发表主题: 菜鸟求助ports安装mysql
这两天刚接触FreeBSD,有问题向大家请教 ^_^
我想在系统里装上mysql
下面是安装步骤:
cd /usr/ports/databases/mysql51-server/
make
make install
make clean
cd work/mysql-5.1.11-beta
scripts/mysql_install_db
出现以下信息:
引用:
Installing all prepared tables
Fill help tables
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/local/bin/mysqladmin -u root password ‘new-password‘
/usr/local/bin/mysqladmin -u root -h freeBSD.domain password ‘new-password‘
See the manual for more instructions.
NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the /usr/local/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!
You can start the MySQL daemon with:
cd /usr/local ; /usr/local/bin/mysqld_safe &
Please report any problems with the /usr/local/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses athttp://shop.mysql.com
mysql
引用:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
mysql服务启动不了. : (
引用:
/usr/local/bin/mysqld_safe &
也是和上面一样的错误
大家请指教.
返回页首

RainFlying
半仙
注册时间: 2005-11-11
文章: 14
发表于: Fri 2007-05-18 12:27:14    发表主题: Re: 菜鸟求助ports安装mysql
mylcx1028 写到:
这两天刚接触FreeBSD,有问题向大家请教 ^_^
我想在系统里装上mysql
下面是安装步骤:
cd /usr/ports/databases/mysql51-server/
make
make install
make clean
cd work/mysql-5.1.11-beta
scripts/mysql_install_db
出现以下信息:
引用:
Installing all prepared tables
Fill help tables
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/local/bin/mysqladmin -u root password ‘new-password‘
/usr/local/bin/mysqladmin -u root -h freeBSD.domain password ‘new-password‘
See the manual for more instructions.
NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the /usr/local/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!
You can start the MySQL daemon with:
cd /usr/local ; /usr/local/bin/mysqld_safe &
Please report any problems with the /usr/local/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses athttp://shop.mysql.com
mysql
引用:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
mysql服务启动不了. : (
引用:
/usr/local/bin/mysqld_safe &
也是和上面一样的错误
大家请指教. :oops:
/usr/local/bin/mysql_install_db --user=mysql试试
_________________
如果大海能够唤回曾经的爱,
就让我用一生等待;
如果深情往事你已不再留恋,
就让他随风飘远;
如果大海能够带走我的哀愁,
就像带走每条河流,
所有受过的伤,
所有流过的泪,
我的爱,
请全部带走
返回页首  


FindFullMoon
半仙
注册时间: 2006-09-04
文章: 96
发表于: Mon 2007-05-21 01:40:12    发表主题: 我也是装的这个.没出现这个问题
以前在LINUX下安装MYSQL的时候 还在烦怎么设置呢.
装好这个PORTS的时候..
我就直接在rc.conf中
mysql_enable="YES"
然后,/usr/local/etc/rc.d/mysql-server start
就直接用了.应该是我还不懂怎么玩mysql吧.
返回页首

wpppl.108
半仙
注册时间: 2007-05-11
文章: 11
发表于: Thu 2007-05-24 22:40:14    发表主题:
我等待!我有同样的问题,但是我是编译安装的!
_________________
FreeBSD交流群16911484!
返回页首

kyclove
半仙
注册时间: 2005-04-16
文章: 11
来自: 福建泉州
发表于: Thu 2007-09-06 16:59:53    发表主题:
我也是刚学的.BSD.我的能启动
/usr/local/bin/./mysql_install_db -u mysql
/usr/local/bin/./mysql_safe -u mysql &
/usr/local/share/mysql/./mysql.server start
试下.
_________________
Administrator
返回页首

dog
半仙
注册时间: 2006-10-12
文章: 48
发表于: Tue 2007-10-16 17:22:43    发表主题:
恩,楼主这个问题我也遇到过,不过当时我是MYSQL档的权限设置没对,所以有问题,楼主可以ls -l查看一下。
如果还是不能解决,我们再讨论。
返回页首

xport
老妖

注册时间: 2004-05-27
文章: 1194
来自: N/A
发表于: Tue 2007-10-16 17:56:25    发表主题: Re: 菜鸟求助ports安装mysql
mylcx1028 写到:
cd /usr/ports/databases/mysql51-server/
make
make install
make clean
cd work/mysql-5.1.11-beta
scripts/mysql_install_db
出现以下信息:
你 clean 后就没有 work 这个目录了!
所以,你得执行这个去建立 MySQL 的系统数据库:
代码:
# /usr/local/bin/mysql_install_db
然后就可以开 MySQL 的数据库服务了:
代码:
# /usr/local/etc/rc.d/mysql-server onestart
Starting mysql.
_________________
http://freebsdchina.org/forum/viewtopic.php?t=36066