Home  >  Article  >  Backend Development  >  ubuntu service 连不上Mysql,该怎么解决

ubuntu service 连不上Mysql,该怎么解决

WBOY
WBOYOriginal
2016-06-13 12:02:251001browse

ubuntu service 连不上Mysql
用的是ubuntu service 12.04版本的,apache 安装没有问题,网页可以访问,mysql服务器本机可以用命令访问。但是用下面的数据库连接代码就不行。 怎么回事啊。
没有跳出错误提示
$con = mysql_connect("localhost","root","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

 $db_selected = mysql_select_db('buy',$con);

if (!$db_selected)
  {
  die ("Can\'t use test_db : " . mysql_error());
  }
------解决方案--------------------
$con = mysql_connect("127.0.0.1","root","123");  可以链接吗?很可能是权限问题。
你ubuntu怎么链接mysql的?
$ mysql -h localhost -u root -p; ?
"show grants" 看看返回什么?
“SELECT user, host FROM mysql.user” 又返回什么?
------解决方案--------------------
不行是指什么? 错误信息是?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn