doushantun0614 2014-07-12 13:58
浏览 34

从raspberry pi连接数据库

I want to echo or print content from a database in my terminal on my raspberry pi. I installed MySql client and PHP5. I want to run a php file in my terminal so i created a file:

<?php

$con = mysqli_connect("mysql51-025.wc1","username","password","dbname")
//first one is hostname

if(mysqli_connect_errno()){
echo "failed to connect with error: ". mysqli_connect_error();
}

?>

When i run this in my terminal on my raspberrypi

pi@raspberrypi ~ $ php database.php

I'll get this returned:

PHP warning: mysqli_connect(): (hy000/2005): Unknown MySQL server host 'nameofmyhostinphpfile' (25) in /home/pi/database.php on line 8 failed to connect with error: Unknown MySql server host 'hostname'

My question is how i can make this connection work. And will i be able to execute queries and echo or print those results on my pi and use those results in shell scripts?

Thank you!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
    • ¥15 安装svn网络有问题怎么办
    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?