• 在数据库中导出文件:

    select * from tb_test01 into outfile 'test.txt';
    ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
    需要在配置文件/etc/my.cnf
    加入:
    secure_file_priv=/tmp
    这个时候可以把文件导入到到/tmp 文件夹内
    select * from tb_test01 into outfile '/tmp/test.txt';

    SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
  • 命令行:

    mysql -uroot -p -e "select * from data1.tb_test01 where id=1;" > /tmp/test01.txt

  • 导出整个表:

    mysqldump -uroot -p data1 tb_test01 > test01.txt
    或者整个数据库: mysqldump -uroot -p data1 > test01.txt

  • 导入数据库:

    mysql -uroot -p data1 < test01.txt
    或者进入mysql: source /tmp/test01.txt

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄