Welcome to Abdul Malik Ikhsan's Blog

Menangani error mysql command line : ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

Posted in mysql docs, tips and tricks by samsonasik on July 6, 2009

Pernahkah anda pas ngerun mysql di command line mengalami error seperti ini ?

errormysql

Nah, cara mengatasinya adalah membuat ‘link’ ke file /var/run/mysqld/mysqld.sock, caranya :

mysqlhandling

View pada Mysql 5.0.41

Posted in mysql docs by samsonasik on July 20, 2007

View bisa dikatakan summary dari tabel atau beberapa tabel, dengan view, kita bisa gabungkan beberapa tabel sekaligus dan view ini tersimpan di sisi server, sehingga nanti penggunaannya tinggal panggil saja, berikut contohnya, :D:\its me\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.41-community-nt MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create database forum;
Query OK, 1 row affected (0.00 sec)

mysql> use forum;
Database changed
mysql> create table barang(kode_barang char(3) not null primary key default’0′,n
ama_barang char(30),harga_barang int);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into barang values(‘001′,’mobil’,50000000);
Query OK, 1 row affected (0.05 sec)

mysql> create table jual(tgl date,kode char(3),jml_jual int);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into jual values(‘2007-01-01′,’001’,3);
Query OK, 1 row affected (0.00 sec)

mysql> create view jualan_view as select DATE_FORMAT(b.tgl,’%d %M %Y’) as tgl,b.kode,a.nama_barang, a.harga_barang,b.jml_jual,(a.harga_barang*b.jml_jual) as total from jual b, barang a where
b.kode=a.kode_barang;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from jualan_view;
==========================================
| tgl  | kode | nama_barang | harga_barang | jml_jual | total  |
===========================================
| 01 January 2007 | 001 | mobil |  50000000  | 3 | 150000000     |
+———————–+——+————-+————–+———-+
1 row in set (0.00 sec)