If you have access on the machine with MySQL and you need to export all tables in a database you can use:
hpatoio@namazu:~$ mysqldump -uroot -p DATABASE_NAME -T '/home/simone/export_csv' --fields-terminated-by "," --fields-enclosed-by '"' --lines-terminated-by "\n"
the script will create a files for each table of the DB and will place it in export_csv.
If you need to export a custom resultset or you need to export data from a remote MySQL server on your machine you can use this command :
hpatoio@namazu:~$ mysql -uroot -h HOSTNAME -p DATABASE_NAME -B -e "select field1,field2 ... fieldX from \`TABLE_NAME\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > my_export.csv
shiftDay = 10
var myDate = new Date();
myDate.setDate(myDate.getUTCDate() + shiftDay)
day = myDate.getUTCDate()
month = myDate.getUTCMonth()*1 + 1
year = myDate.getUTCFullYear()
This code is quite easy:
Here some slang/vocabulary from the english course “Rain dogs”
Oh no ! It happend again !!
The sysadmin turned on the gpc_magic_quotes and you got the DB full of \’
Here a fast way to get back the correct values.
UPDATE table_name SET field_name = REPLACE(field_name,’\”’,””)
For security reason, MySQL doesn’t allow access from other computer.
If you try to connect with a MySQL administration client like MySQL Administrator you will get a Mysql Error Number 2003.
All this operations modify system settings, so they must be executed with root privileges
If you want connect from a computer in your LAN to your mysql server you have to :
root@namazu:~#sudo vi /etc/mysql/my.conf
and change the line
bind-address = 127.0.0.1
with
bind-address = 192.168.178.100
To apply the changes you have to reload the MySQL server
root@namazu:~#sudo /etc/init.d/mysql start
This make MySQL listen on your external interface.
Run the MySQL client
root@namazu:~#mysql
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 to server version: 5.0.22-Debian_0ubuntu6.06-log Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
Modify access privileges to the server
mysql>GRANT ALL PRIVILEGES ON DB_NAME.* TO ‘USERNAME‘@’HOST‘ IDENTIFIED BY ‘PASSWORD‘;
Exit the client
mysql>exit
Reload the privileges
root@namazu:~#mysqladmin reload
For more info on GRANT command: GRANT Syntax on MySQL Reference Manual
Have fun …
From a shell run
mysql -u USER -p DBNAME < dump.sql
then insert the password and is done.
Create or open the file .htaccess and add this line
php_value display_errors On