cara masuk mysql di ubuntu

cara masuk mysql

ilham@ilham-System-Product-Name:~$ sudo su
[sudo] password for saefull:
root@saefull-System-Product-Name:/home/saefull# /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 947

root@saefull-System-Product-Name:/home/saefull# mysql -u petik -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.1.63-0ubuntu0.11.10.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user from user;
+------------------+
| user             |
+------------------+
| saeful@localhost |
| root             |
| debian-sys-maint |
| petik            |
| root             |
| root             |
+------------------+
6 rows in set (0.00 sec)

mysql> \q
Bye
root@saefull-System-Product-Name:/home/saefull# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.1.63-0ubuntu0.11.10.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE kepegawaian;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kepegawaian        |
| mysql              |
| petik              |
+--------------------+
4 rows in set (0.00 sec)

mysql> use kepegawaian;
Database changed
mysql> SHOW TABLES;
Empty set (0.00 sec)

mysql> CREATE TABLE divisi(
    -> id int primary key auto_increment,
    -> nama varchar(20) NOT NULL unique
    -> );
Query OK, 0 rows affected (0.08 sec)

mysql> show tables;
+-----------------------+
| Tables_in_kepegawaian |
+-----------------------+
| divisi                |
+-----------------------+
1 row in set (0.00 sec)

mysql> CREATE TABLE jabatan(
    -> id int primary key auto_increment,
    -> nama varchar(20) NOT NULL unique
    -> );
Query OK, 0 rows affected (0.08 sec)

mysql> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql> show tables;
+-----------------------+
| Tables_in_kepegawaian |
+-----------------------+
| divisi                |
| jabatan               |
+-----------------------+
2 rows in set (0.00 sec)

mysql> CREATE TABLE pegawai(
    -> id int primary key auto_increment,
    -> nama varchar(32) NOT NULL,
    -> tmp_lahir varchar(32) NOT NULL,
    -> tgl_lahir date NOT NULL,
    -> alamat text NOT NULL,
    -> tgl_masuk date NOT NULL,
    -> iddivisi int REFERENCES divisi(id),
    -> idjabatan int REFERENCES jabatan(id)
    -> );
Query OK, 0 rows affected (0.06 sec)

mysql> DESC pegawai;
+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| id        | int(11)     | NO   | PRI | NULL    | auto_increment |
| nama      | varchar(32) | NO   |     | NULL    |                |
| tmp_lahir | varchar(32) | NO   |     | NULL    |                |
| tgl_lahir | date        | NO   |     | NULL    |                |
| alamat    | text        | NO   |     | NULL    |                |
| tgl_masuk | date        | NO   |     | NULL    |                |
| iddivisi  | int(11)     | YES  |     | NULL    |                |
| idjabatan | int(11)     | YES  |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)

mysql> CREATE TABLE gaji(
    -> id int primary key auto_increment,
    -> gaji_pokok decimal NOT NULL,
    -> tunjangan decimal,
    -> tunkes decimal,
    -> transport decimal,
    -> idpegawai int REFERENCES pegawai(id)
    -> );
Query OK, 0 rows affected (0.07 sec)

mysql> INSERT INTO divisi(nama) VALUES
    -> ('keuangan'),
    -> ('personalia'),
    -> ('IT'),
    -> ('marketing')
    ->

Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM divisi;
+----+------------+
| id | nama       |
+----+------------+
|  1 | keuangan   |
|  2 | personalia |
|  3 | IT         |
|  4 | marketing  |
+----+------------+
4 rows in set (0.00 sec)

mysql> INSERT INTO divisi(nama) VALUES ('SDM');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM divisi;
+----+------------+
| id | nama       |
+----+------------+
|  1 | keuangan   |
|  2 | personalia |
|  3 | IT         |
|  4 | marketing  |
|  5 | SDM        |
+----+------------+
5 rows in set (0.00 sec)

mysql> INSERT INTO jabatan(nama) VALUES
    -> ('Direktur'),
    -> ('Manager'),
    -> ('Ka.SDM'),
    -> ('Ka.Marketing'),
    -> ('Ka.Personalia'),
    -> ('Ka.Keuangan'),
    -> ('Customer service')
    -> ;
Query OK, 7 rows affected (0.00 sec)
Records: 7  Duplicates: 0  Warnings: 0

mysql> SELECT nama FROM jabatan;
+------------------+
| nama             |
+------------------+
| Customer service |
| Direktur         |
| Ka.Keuangan      |
| Ka.Marketing     |
| Ka.Personalia    |
| Ka.SDM           |
| Manager          |
+------------------+
7 rows in set (0.00 sec)

mysql> SELECT * FROM divisi
    -> ;
+----+------------+
| id | nama       |
+----+------------+
|  1 | keuangan   |
|  2 | personalia |
|  3 | IT         |
|  4 | marketing  |
|  5 | SDM        |
+----+------------+
5 rows in set (0.00 sec)

mysql> SELECT * FROM jabatan;
+----+------------------+
| id | nama             |
+----+------------------+
|  1 | Direktur         |
|  2 | Manager          |
|  3 | Ka.SDM           |
|  4 | Ka.Marketing     |
|  5 | Ka.Personalia    |
|  6 | Ka.Keuangan      |
|  7 | Customer service |
+----+------------------+
7 rows in set (0.00 sec)

mysql> INSERT INTO pegawai(nama, tmp_lahir, tgl_lahir, alamat, tgl_masuk, iddivisi, idjabatan) VALUES
    -> ('Kusnadi', 'Tanggerang', '1990-10-2', 'Depok', '2012-07-10', 4, 1),
    -> ('Panji', 'Bogor', '1995-01-26', 'Cariu', '2012-08-20', 2, 5),
    -> ('Ikbar', 'Sukabumi', '1992-06-23', 'Sukamanah', '2012-03-12', 5, 4),
    -> ('Nazih', 'Pekalongan', '1992-09-04', 'Paesan', '2012-05-19', 1, 6)
    -> ;
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM pegawai;
+----+---------+------------+------------+-----------+------------+----------+-----------+
| id | nama    | tmp_lahir  | tgl_lahir  | alamat    | tgl_masuk  | iddivisi | idjabatan |
+----+---------+------------+------------+-----------+------------+----------+-----------+
|  1 | Kusnadi | Tanggerang | 1990-10-02 | Depok     | 2012-07-10 |        4 |         1 |
|  2 | Panji   | Bogor      | 1995-01-26 | Cariu     | 2012-08-20 |        2 |         5 |
|  3 | Ikbar   | Sukabumi   | 1992-06-23 | Sukamanah | 2012-03-12 |        5 |         4 |
|  4 | Nazih   | Pekalongan | 1992-09-04 | Paesan    | 2012-05-19 |        1 |         6 |
+----+---------+------------+------------+-----------+------------+----------+-----------+
4 rows in set (0.00 sec)

mysql> UPDATE pegawai set alamat='Rangkepan Jaya' where id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT * FROM pegawai;
+----+---------+------------+------------+----------------+------------+----------+-----------+
| id | nama    | tmp_lahir  | tgl_lahir  | alamat         | tgl_masuk  | iddivisi | idjabatan |
+----+---------+------------+------------+----------------+------------+----------+-----------+
|  1 | Kusnadi | Tanggerang | 1990-10-02 | Rangkepan Jaya | 2012-07-10 |        4 |         1 |
|  2 | Panji   | Bogor      | 1995-01-26 | Cariu          | 2012-08-20 |        2 |         5 |
|  3 | Ikbar   | Sukabumi   | 1992-06-23 | Sukamanah      | 2012-03-12 |        5 |         4 |
|  4 | Nazih   | Pekalongan | 1992-09-04 | Paesan         | 2012-05-19 |        1 |         6 |
+----+---------+------------+------------+----------------+------------+----------+-----------+
4 rows in set (0.00 sec)

mysql> UPDATE pegawai set alamat='Marinir' whwere='Nazih';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'whwere='Nazih'' at line 1
mysql> SELECT * FROM pegawai;
+----+---------+------------+------------+----------------+------------+----------+-----------+
| id | nama    | tmp_lahir  | tgl_lahir  | alamat         | tgl_masuk  | iddivisi | idjabatan |
+----+---------+------------+------------+----------------+------------+----------+-----------+
|  1 | Kusnadi | Tanggerang | 1990-10-02 | Rangkepan Jaya | 2012-07-10 |        4 |         1 |
|  2 | Panji   | Bogor      | 1995-01-26 | Cariu          | 2012-08-20 |        2 |         5 |
|  3 | Ikbar   | Sukabumi   | 1992-06-23 | Sukamanah      | 2012-03-12 |        5 |         4 |
|  4 | Nazih   | Pekalongan | 1992-09-04 | Paesan         | 2012-05-19 |        1 |         6 |
+----+---------+------------+------------+----------------+------------+----------+-----------+
4 rows in set (0.00 sec)

mysql> UPDATE pegawai set alamat='Marinir' where='Nazih';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='Nazih'' at line 1
mysql> UPDATE pegawai set alamat='Marinir' where nama='Nazih';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT * FROM pegawai;
+----+---------+------------+------------+----------------+------------+----------+-----------+
| id | nama    | tmp_lahir  | tgl_lahir  | alamat         | tgl_masuk  | iddivisi | idjabatan |
+----+---------+------------+------------+----------------+------------+----------+-----------+
|  1 | Kusnadi | Tanggerang | 1990-10-02 | Rangkepan Jaya | 2012-07-10 |        4 |         1 |
|  2 | Panji   | Bogor      | 1995-01-26 | Cariu          | 2012-08-20 |        2 |         5 |
|  3 | Ikbar   | Sukabumi   | 1992-06-23 | Sukamanah      | 2012-03-12 |        5 |         4 |
|  4 | Nazih   | Pekalongan | 1992-09-04 | Marinir        | 2012-05-19 |        1 |         6 |
+----+---------+------------+------------+----------------+------------+----------+-----------+
4 rows in set (0.00 sec)

mysql> B

0 komentar:

Posting Komentar

Blogger news

http://pagead2.googlesyndication.com/simgad/3448508448364612491