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 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程