MySQL数据库到.txt文件 [英] Mysql database to .txt file

查看:96
本文介绍了MySQL数据库到.txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将来自我的mysql数据库的所有电子邮件地址都放在一个文本文件中. 每当有一个新的注册时,我都会创建一个, 所以通常我应该将此代码放在我的register.php中:

I want to put al the emailaddresses from my mysql database in a text file. I would to create this each time some one new is registered, so normally; I should put this code in my register.php:

(连接到数据库后):

mysql_query("SELECT mail FROM users INTO OUTFILE 'test.txt'") or die("failed");

但是我总是得到失败"的消息.这段代码有什么问题,或者还有其他方法吗?

But I always get the "failed". What is wrong in this code, or is there an other way?

谢谢!

推荐答案

Francis,

一个更简单的方法是从外壳执行查询:

A much simpler method to do this would be to simply execute the query from the shell:

mysql databasename -e "SELECT mail FROM users" > test.txt

这篇关于MySQL数据库到.txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆