[root@kvm3 ~]# mycli -uroot -p123qwe Connecting to socket /var/lib/mysql/mysql.sock, owned by user mysql MariaDB 10.5.16 mycli 1.26.1 Home: http://mycli.net Bug tracker: https://github.com/dbcli/mycli/issues Thanks to the contributor - Jerome Provensal
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.028s
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' f -> ields terminated by ',' enclosed by '"' lines terminated -> by '\r\n'; Query OK, 4 rows affected Time: 0.013s MariaDB root@(none):dyw> quit; Goodbye!
[root@kvm3 ~]# find /tmp/systemd-private-* -name animals.txt /tmp/systemd-private-0a153b804a324bf49246a6dd422cc22b-mariadb.service-3gFnjh/tmp/animals.txt
[root@kvm3 ~]# find /tmp/systemd-private-* -name animals.txt -exec cat {} \; 1 dog 4 2 cat 4 3 chicken 2 15 bird 2
[root@kvm3 ~]# find /tmp/systemd-private-* -name animals1.txt -exec cat {} \; "1","dog","4" "2","cat","4" "3","chicken","2" "15","bird","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