Riding The Breeze

Jump to content

Additional information

Categories


Posts filed in ‘Things I forget’


CSV export from MySQL

Sep 2007
15

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


Add days to a date in javascript

May 2007
30

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:


MSSQL | Convert unix timestamp to date

Apr 2007
24

select dateadd(ss, {field_name}, '19700101')


Slang

Nov 2006
02

Here some slang/vocabulary from the english course “Rain dogs”

Yes man - Brown nose
Lecchino, paraculo
Shitting bricks
Avere paura, ironico
Spew
Vomitare
Bill
Banconota in americano, conto in inglese
Note
Banconote in inglese
Check
Conto in americano, assegno in inglese
Jack the ripper
Jack lo squartatore

Ops …

Oct 2006
08

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,’\”’,””)


Access Mysql from other machines

Aug 2006
29

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 :

1) Edit your MySQL configuration file

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.

2) Give grants

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 …


Import dump in MySQL

Jul 2006
17

From a shell run

mysql -u USER -p DBNAME < dump.sql

then insert the password and is done.


Enable display errors for PHP

Jun 2006
24

Create or open the file .htaccess and add this line

php_value display_errors On


Paging

Credits

Template designed by praegnanz.de.