首页 / Mysql / php 不能连接数据库 php error Can't connect to local MySQL server

php 不能连接数据库 php error Can't connect to local MySQL server

测试的php文件 <?php $link=mysql_…

测试的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

本文来自网络,不代表我是攻城狮立场,转载请注明出处:https://www.54gcs.cn/sql/mysql/672.html

helwo作者

上一篇
下一篇

为您推荐

发表评论

联系我们

联系我们

在线咨询: QQ交谈

邮箱: web@5vo.cn

工作时间:周一至周五,9:00-17:30,节假日休息
关注微信
微信扫一扫关注我们

微信扫一扫关注我们

手机访问
手机扫一扫打开网站

手机扫一扫打开网站

返回顶部
跳至工具栏