Posted by: M'Creative | 5 August 2011

Adding MySQL user


Palangka, jum’at 5 ramadhan 1423 H

1. Gunakan koneksi ssh ke server / MySQL server – penulis menggunakan ubuntu 11.04

#ssh -Y bloon@192.168.18.131
bloon@192.168.18.131’s password:
Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-10-generic i686)
* Documentation:  https://help.ubuntu.com/
0 packages can be updated.
0 updates are security updates.
Last login: Thu Aug  4 15:39:40 2011 from 1.1.1.33
bloon@ubuntu:~$

2. Jalankan perintah sudo secara permanen

bloon@ubuntu:~$sudo su

3. Jalankan MySql client dengan user yang mempunyai hak akses SU

//-h : host mysql server
//-u : username
//-p : password

root@ubuntu:#mysql -h 127.0.0.1 -u root -p
The program ‘mysql’ can be found in the following packages:
* mysql-client-core-5.1
* mysql-cluster-client-5.1
Try: apt-get install <selected package>

Oppsss, mysql-client belum terpasang

4. Pasang mysql-client

root@ubuntu:#apt-get install mysql-client-core-5.1
Reading package lists…
Done Building dependency tree
Reading state information…
Done The following packages were automatically installed and are no longer required:   linux-headers-2.6.38-8 linux-headers-2.6.38-8-generic Use ‘apt-get autoremove’ to remove them. The following extra packages will be installed:   libmysqlclient16 mysql-common The following NEW packages will be installed:   libmysqlclient16 mysql-client-core-5.1 mysql-common 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,911 kB of archives.
After this operation, 4,563 kB of additional disk space will be used. Do you want to continue [Y/n]? y
Get:1 http://pandawa.ipb.ac.id/ubuntu/ natty/main mysql-common all 5.1.54-1ubuntu4 [12.2 kB] Get:2 http://pandawa.ipb.ac.id/ubuntu/ natty/main libmysqlclient16 i386 5.1.54-1ubuntu4 [1,808 kB] Get:3 http://pandawa.ipb.ac.id/ubuntu/ natty/main mysql-client-core-5.1 i386 5.1.54-1ubuntu4 [90.8 kB] Fetched 1,911 kB in 22s (86.4kB/s)
Selecting previously deselected package mysql-common.
(Reading database … 157049 files and directories currently installed.)
Unpacking mysql-common (from …/mysql-common_5.1.54-1ubuntu4_all.deb) …
Selecting previously deselected package libmysqlclient16.
Unpacking libmysqlclient16 (from …/libmysqlclient16_5.1.54-1ubuntu4_i386.deb) …
Selecting previously deselected package mysql-client-core-5.1.
Unpacking mysql-client-core-5.1 (from …/mysql-client-core-5.1_5.1.54-1ubuntu4_i386.deb) …
Processing triggers for man-db … Setting up mysql-common (5.1.54-1ubuntu4) … Setting up libmysqlclient16 (5.1.54-1ubuntu4) … Setting up mysql-client-core-5.1 (5.1.54-1ubuntu4) …
Processing triggers for libc-bin … ldconfig deferred processing now taking place

5. Jalankan lagi mysql client

bloon@ubuntu:#mysql -h 127.0.0.1 -u root -p
Welcome to the MySQL monitor.
Commands end with ; or \g. Your MySQL connection id is 1767 Server version: 5.5.8 Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>

6. Sekarang buat user. Ada banyak cara, ini yang saya anggap paling mudah dan cepat

mysql> CREATE USER ‘bego’@’localhost’ IDENTIFIED BY ‘bego_pass’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘bego’@’localhost’  WITH GRANT OPTION;
mysql> CREATE USER ‘bloon’@’%’ IDENTIFIED BY ‘bloon_pass’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘bloon’@’%’ WITH GRANT OPTION;
mysql> CREATE USER ‘ndableg’@’localhost’;
mysql> GRANT RELOAD,PROCESS ON *.* TO ‘admin’@’localhost’;
mysql> CREATE USER ‘blee’@’localhost’;

user bego hanya bisa diakes dari localhost (‘bego’@’localhost‘) dengan akses SU
user bloon bisa diakses dari mana saja (‘bloon’@’%‘) dengan akses SU
user ndableg hanya bisa diakses dilocalhost dengan akses terbatas “RELOAD” dan “PROCCESS”
user blee hanya bisa diakses di localhost tanpa akses – belum bisa digunakan. bisa di tambah lain waktu
7. Test user Pastikan mysql client sudah terpasang Bikin tab terminal baru (ctrl+shift+t)

root@us-djafa:/home/djafa# mysql -h 192.168.18.131 -u bloon -p
Enter password:
Welcome to the MySQL monitor.
Commands end with ; or \g.
Your MySQL connection id is 1872 Server version: 5.5.8 Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement. mysql>

Alhamdulillah proses penambahanMySQL user selesai


Responses

  1. […] 6. Buat user baru https://palawa.wordpress.com/2011/08/05/adding-mysql-user/ […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: