Some mysql sql basic command I must remember

I use phpmyadmin in daily environment, do I still know  sql command?

My sql file too large, it’s hard to import using phpmyadmin, please help me

Some question around mysql from my student, my false make them spoil using phpmyadmin all day long 🙂

Here’s my answers :

1. Command to create database

create database databasename

2. Delete database

drop database databasename

3. Import database

mysql -uusername -ppassword databasename < databasename.sql

4. Export database

mysqldump -uusername -ppassword databasename > databasename.sql

5. Pick database and choose one to manage

use databasename

6. List all table in database

show tables

 Illustration in mysql command line :

read more »

php 5.2.3 ports

New release php5.2.3 make me curious to test upgrade from php4.4.7 to php5.2.3

kongja# cd /usr/ports/lang/php5


kongja# ee Makefile


PORTNAME=       php5
CATEGORIES?=    lang devel www


kongja# make fetch

=> php-5.2.3.tar.bz2 is not in /data3/ports/lang/php5/distinfo.
=> Either /data3/ports/lang/php5/distinfo is out of date, or
=> php-5.2.3.tar.bz2 is spelled incorrectly.
*** Error code 1

kongja# ee distinfo

MD5 (php-5.2.2.tar.bz2) = d084337867d70b50a10322577be0e44e
SHA256 (php-5.2.2.tar.bz2) = cd69e73c46e1d171ac0cf27b7ee492c3bf8f6b45a763a77fd0cb79d5afa9f407
SIZE (php-5.2.2.tar.bz2) = 7310926
MD5 (suhosin-patch-5.2.2- = 081fe08d584820a6ece1fe2e8629711f
SHA256 (suhosin-patch-5.2.2- = 932d8155028686b96d3ebf89215dab7cd9353ac72f9ea82c252d0999fb4bd864
SIZE (suhosin-patch-5.2.2- = 22850
MD5 (php-5.2.2-mail-header.patch) = 6b2562b5230b1f85a2ccb292e124a91a
SHA256 (php-5.2.2-mail-header.patch) = 5394732be1953c7eedc2de9529d10971d85959af6352c8a67b4561124ddc8df5
SIZE (php-5.2.2-mail-header.patch) = 3420

                                        Options for php5 5.2.3                       
                            │ ┌────────────────────────────────────────────────────────────────┐ │
                            │ │  [X] CLI        Build CLI version                              │ │
                            │ │  [ ] CGI        Build CGI version                              │ │
                            │ │  [X] APACHE     Build Apache module                            │ │
                            │ │  [ ] DEBUG      Enable debug                                   │ │
                            │ │  [X] SUHOSIN    Enable Suhosin protection system               │ │
                            │ │  [ ] MULTIBYTE  Enable zend multibyte support                  │ │
                            │ │  [ ] IPV6       Enable ipv6 support                            │ │
                            │ │  [ ] MAILHEAD   Enable mail header patch                       │ │
                            │ │  [ ] REDIRECT   Enable force-cgi-redirect support (CGI only)   │ │
                            │ │  [ ] DISCARD    Enable discard-path support (CGI only)         │ │
                            │ │  [ ] FASTCGI    Enable fastcgi support (CGI only)              │ │
                            │ │  [ ] PATHINFO   Enable path-info-check support (CGI only)      │ │
                            │ │                                                                │ │
                            │ │                                                                │ │
                            │ │                                                                │ │
                                                    [  OK  ]       Cancel

===>  php5-5.2.3 : Your apache does not support DSO modules.
*** Error code 1

Stop in /data3/ports/lang/php5.
*** Error code 1

Stop in /data3/ports/lang/php5.

hehehehe, I should wait for official ports 😉

FreeBSD new logo on T-shirts

Just try to spread the word 🙂

FreeBSD mall put new t-shirts, see below example t-shirts + FreeBSD new logo that pick from their place

I love that design with silk screen

Wanna yours?, then go visit FreeBSD mall

p.s : get the full news from  Florent  Thoumie blog

Insert data when empty and update it when data exist

With so many function provided in mysql plus lazy, It seem like finding gem for replace my old approach 🙂

duplicate data isn’t good, I must search for exisiting data, in general : insert data to table when no data with that value exist and update table if data exist

For example :

I have table A with field :

1. id, integer 11 primary key auto increment

2. name, varchar 25

3. address, varchar 100

4. phone, varchar 20

5. username, varchar 10 unique

a common operation to insert data is :

Checking for data, ex :

$check_data = mysql_query("select * from A where username =’$user’");
if(mysql_num_rows($check_data)>0) {
do update data
mysql_query("update A set bla..bla..bla");
else {
insert query here
mysql_query("insert into A bla..bla..bla");

after find "replace()"

mysql_query("replace into A (field1,field2)  values(‘values1′,’values2’)")

Yes, I still need to do research for another ‘glitch’ possibility in current application.

From mysql manual :

As long index exist for that table, like primary key or unique for helping mysql to find duplicate data or not.

Yes, replace don’t insert please  😉


php5 3 years old and php4 7 years old

php 5.2.3 release!


"The PHP development team would like to announce the immediate availability of PHP 5.2.3. This release continues to improve the security and the stability of the 5.X branch as well as addressing two regressions introduced by the previous 5.2 releases. These regressions relate to the timeout handling over non-blocking SSL connections and the lack of HTTP_RAW_POST_DATA in certain conditions. All users are encouraged to upgrade to this release."

I’ll do upgrade for my box but my hosting service still use 5.1.2 ( from phpinfo() ).

While php4 already  reach 7 years of deployment make this version still in my favourite ( I install php4 as apache module and php5 as cgi)

for windows user xampp or wamp provide the latest version of php for complete. Switch to php4 and php5 very easy as switch menu available.

with slow migration php4 to php5 then php6 become more difficult to adopt since it force user to make secure programming with superglobals and register_globals Off.

Life is option so with the php version 🙂

Oh no, fedora 7 is out too, no ‘core’ , just plain fedora in the name.

time for wget 😉