测试的php文件
<?php
$link=mysql_connect('localhost','root','zz') or die(mysql_error());
mysql_select_db('test') or die('no db');
mysql_query('SET NAMES utf8');
echo 99;
?>
运行后报错
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
但在 命令行中能进入mysql
[root@localhost local]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.5.2-m2 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
解决办法
chown -R root /usr/local/mysql
chgrp -R mysql /usr/local/mysql
chown -R root /usr/local/mysql/bin
chgrp -R mysql /usr/local/mysql/bin
chgrp -R mysql /var/lib/mysql
chmod 777 /var/lib/mysql
chown -R root /var/lib/mysql/mysql
chgrp -R mysql /var/lib/mysql/mysql
chmod 777 /var/lib/mysql/mysql
chown -R root /var/lib/mysql/mysql/*
chgrp -R mysql /var/lib/mysql/mysql/*
chmod 777 /var/lib/mysql/mysql/*
chmod 777 /usr/local/mysql/lib/mysql/libmysqlclient.a
php 不能连接数据库 php error Can't connect to local MySQL server_Mysql
时间: 2024-09-10 07:28:52
php 不能连接数据库 php error Can't connect to local MySQL server_Mysql的相关文章
error: &;#39;Can&;#39;t connect to local MySQL server through socket &;#39;/var/lib/mysql/mysql.sock&;#39; (2)&;#39;
[root@luozhonghua ~]# /usr/bin/mysqladmin -u root password 'aaaaaa' /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' Check that mysqld is runni
ERROR 2002 (HY000): Can&#039;t connect to local MySQL server through socket &#039;/var/lib/mysql/mysql.sock&#039; (2)
从供应商手中接手一个云平台(Windwos Azure)上的MySQL数据库,登录数据库时遇到错误: $mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 检查配置文件/etc/my.cnf发现供应商修改了mysql数据库的数据存储目录,另外mysql.sock文件位置也变更为了/
ERROR 2002 (HY000): Can&;#39;t connect to local MySQL server through socket &;#39;/var/lib/mysql/mysql.sock&;#39; (
mysql启动成功 service mysqld start mysql is OK mysql登录错误 : [root@localhost ~]# mysql -uroot -p123456ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 解决: vim /etc/my.cnf 找到 socket路径 scoket=/tmp/mysql.
MYSQL错误解决:ERROR 2002 (HY000): Can&#039;t connect to local MySQL server through socket &#039;/var/lib/mysql/mysql.sock&#039; (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 据说这个问题的原因很多,当然,我自己这个问题我是清楚的,就是mysql.sock的位置所致,一个是PHP要求的,一个是MYSQLD定义的,一个是MY.CONF指定的...SO.... 暂时不能统一的话,用软链接LN -S命令解决吧.. 方案5 摘要:解决不能通过mysql .so
MySQL错误ERROR 2002 (HY000): Can&#039;t connect to local MySQL server through socket_Mysql
在安装好了MySQL之后,使用了新的配置文件后,MySQL服务器可以成功启动,但在登陆的时候出现了ERROR 2002 (HY000): Can't connect to local MySQL server through socket,即无法通过socket连接到mysql服务器,同时提供了socket文件的位置.下面是这个问题的描述与解决办法. 1.故障现象 复制代码 代码如下: [root@SZDB mysqldata]# mysql -uroot -p123456 Warning: U
MYSQL错误解决:ERROR 2002 (HY000): Can&;#39;t connect to local MySQL server through socket &;#39;/var/lib/mysql/mysql.sock&;#39; (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 据说这个问题的原因很多,当然,我自己这个问题我是清楚的,就是mysql.sock的位置所致,一个是PHP要求的,一个是MYSQLD定义的,一个是MY.CONF指定的...SO.... 暂时不能统一的话,用软链接LN -S命令解决吧.. 方案5 摘要:解决不能通过mysql .so
ERROR 2002 (HY000): Can&#039;t connect to local MySQL server through socket
在安装好了MySQL之后,使用了新的配置文件后,MySQL服务器可以成功启动,但在登陆的时候出现了ERROR 2002 (HY000): Can't connect to local MySQL server through socket,即无法通过socket连接到mysql服务器,同时提供了socket文件的位置.下面是这个问题的描述与解决办法. 1.故障现象[root@SZDB mysqldata]# mysql -uroot -p123456Warning: Using a
ERROR 2002 (HY000): Cant connect to local MySQL server through socket的解决方法
连接MySQL提示ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)的解决方法 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 原文:http://www.aiezu.com/db/mysql_cant_connect_thro
在mac osx10.6下安装mysql后,启动总是报错ERROR 2002 (HY000): Can&;#039;t connect to local MySQL ser
问题描述 要在mac10.6下安装mysql以便rails开发,装了两天都没有成功.之前没用过mac或linux开发,一直用windows,所以希望高手们能指点一下.我在安装时参考了以下文章:http://beike.iteye.com/blog/617341http://hqman.iteye.com/blog/258979下面是我的安装过程及错误:安装和初始化mysqlport search mysqlsudo port install mysql5-server解决方案二: 解决方案三: