How do I export from MYSQL to CSV in mariadb on Centos 7?
I am using:
Server version 5.5.37-MariaDB
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
on CentOS Linux release 7.0.1406 (Core)
I tried the following:
mysql> SELECT *
-> INTO OUTFILE 'cd /var/foo.csv'
-> FIELDS TERMINATED BY ','
-> ENCLOSED BY '"'
-> ESCAPED BY '\\'
-> LINES TERMINATED BY '\r\n'
-> FROM foo;
Query OK, 4079 ROWS affected (0.02 sec)
Where foo is the database name? But it gives me a syntax error. Do I not have to select a particular table?
Then I tried this :
mysql -u root -p enterpass nameofdb -B -e “select * from \`person\`;” | sed ‘s/\t/”,”/g;s/^/”/;s/$/”/;s/\n//g’ > nameofdb.csv
Same again with syntax error.
I am practicing this so I can see if I could manually migrate one kind of database store into another. A zen cart db to an open cart one without having to use some paid product like cart2cart and mainly so I can see the guts of the stores to better understand.
mysqldump > foo.sqlold database/engine ;mysql < foo.sqlnew database/engine.