[root@kvm3 ~]# mycli -uroot -p123qwe Connecting to socket /var/lib/mysql/mysql.sock, owned by user mysql MariaDB 10.11.11 mycli 1.40.0 Home: http://mycli.net Bug tracker: https://github.com/dbcli/mycli/issues Thanks to the contributor - Anonymous MariaDB root@(none):(none)>
MariaDB root@(none):(none)> use dyw; You are now connected to database "dyw" as user "root" Time: 0.002s
SELECT ... INTO OUTFILE 匯出資料到檔案 animals.tex。
MariaDB root@(none):dyw> select * from animals into outfile '/tmp/animals.txt'; Query OK, 4 rows affected Time: 0.006s
MariaDB root@(none):dyw> select * from animals into outfile '/tmp/animals.txt'; (1086, "File '/tmp/animals.txt' already exists")
SELECT ... INTO OUTFILE 並指定格式匯出資料到檔案 animals1.txt。
MariaDB root@(none):dyw> select * from animals into outfile '/tmp/animals1.txt'
-> fields terminated by ',' enclosed by '"' lines termina
-> ted by '\r\n';
Query OK, 4 rows affected
Time: 0.003s
MariaDB root@(none):dyw> quit; Goodbye!
[root@kvm3 ~]# ll /tmp/animals* ls: cannot access '/tmp/animals*': No such file or directory
[root@kvm3 ~]# find /tmp -name animals* /tmp/systemd-private-b37aaef96531415ba6dd83a28a9f9e97-mariadb.service-fpcLqi/tmp/animals.txt /tmp/systemd-private-b37aaef96531415ba6dd83a28a9f9e97-mariadb.service-fpcLqi/tmp/animals1.txt
[root@kvm3 ~]# find /tmp -name animals.txt -exec cat {} \;
1 dog 4
2 cat 4
3 bird 2
4 chicken 2
[root@kvm3 ~]# find /tmp -name animals1.txt -exec cat {} \;
"1","dog","4"
"2","cat","4"
"3","bird","2"
"4","chicken","2"
[root@kvm3 ~]# grep PrivateTmp /etc/systemd/system/multi-user.target.wants/mariadb.service PrivateTmp=false [root@kvm3 ~]# systemctl daemon-reload [root@kvm3 ~]# systemctl restart mariadb.service