时间:2021-05-24
测试的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
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1、数据库的字段:2、php连接数据库获取数据库的信息放入json_encode($css);{文件为:db.php}connect_error);}//设置查
一.PHP对连接数据库的步骤:1与数据库建立连接:$conn=mysql_connect("localhost:3306","username","pass")
php操作mysql步骤:1.$connect=mysql_connect('localhost','root','123456')ordie('数据库连接失败
PHP简易用户登录系统,供大家参考,具体内容如下最近刚刚看到PHP连接数据库的实例,于是做了一个简易的用户系统直接上代码连接数据库:connect.phpcon
一、连接数据库 1、mysql_connect:开启MySQL链接 mysql_connect('主机','用户名','密码')2、mysql_select_