[英]moving my sql database localhost to live server
i want to move my sql database and i have exported and imported mysql.sql file from localhost to live server and now im not getting the files and content from that database. 我想移动我的sql数据库,并且已经将mysql.sql文件从localhost导出并导入到实时服务器,现在我没有从该数据库中获取文件和内容。 what i do ?
我所做的 ? i did make sure connection to database if fine and successful
我确实确保如果成功可以连接到数据库
here's my page http://shooop23.byethost7.com 这是我的页面http://shooop23.byethost7.com
<?php
$db = mysqli_connect('','','','');
if(mysqli_connect_errno()){
echo'Database Connection Failed with following errors: '. mysqli_connect_errno();
die();
}
?>
Once you have successfully established a connection to MySQL, you need to perform a query specifying what you want to retrieve and then subsequently retrieve it. 成功建立与MySQL的连接后,需要执行查询以指定要检索的内容,然后再检索它。
The following example uses mysqli_fetch_row 以下示例使用mysqli_fetch_row
You should explore the documentation to learn the basics. 您应该浏览文档以学习基础知识。
$db = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');
if(mysqli_connect_errno()){
echo'Database connection failed with the following error: '.mysqli_connect_errno();
exit;
}
if ($result = mysqli_query($db, "SELECT MyCol1,MyCol2 FROM MyTable")) {
while ($row = mysqli_fetch_row($result)) {
echo"{$row[0]} - {$row[1]}<br>");
}
mysqli_free_result($result);
}
mysqli_close($db);
$db = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');
$sql="SELECT * FROM login";
here i connected and stored my database and set a sql command (which is now a string) into these two veriables. 在这里,我连接并存储了数据库,并在这两个Veriable中设置了一个sql命令(现在是一个字符串)。
if(mysqli_connect_errno()){
echo'Database connection failed with the following error: '.mysqli_connect_errno();
exit;
}
this is to check if the database is correctly connected, if not then it will show some errors. 这是为了检查数据库是否正确连接,否则将显示一些错误。
$result = mysqli_query($db,$sql);
here i put the database and the sql command to run my query. 在这里,我将数据库和sql命令用于运行查询。
while($row = mysqli_fetch_array($result)){
echo $row['username'];
}
here finally outputting the usernames(username is one of the column in my table in this case) which matched with that query i will suggest This Sql site to get a better understanding on sql queries and try to improve the secuirty because this is the basic point where hackers try to inject their attact most offenly. 在这里,最后输出与该查询匹配的用户名(在这种情况下,用户名是我的表中的列之一),我将建议此Sql网站更好地理解sql查询并尝试提高安全性,因为这是基本要点黑客试图最讨厌地攻击他们的地方。 Note : If your table's in the database are empty then it will not able to fetch anything
注意:如果数据库中的表为空,则它将无法获取任何内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.