Adding MySQL user via Command Line, Menambah MySQL user dengan Command Line

0
11680
Halaman:
Sertakan sumber dengan jelas jika ingin mencopy. Selalu cek tanggal, karena mungkin ada beberapa artikel lama yang belum disesuaikan dengan fakta terbaru
  1. Connect to machine via ssh - writer using ubuntu 11.04
    #ssh -Y [email protected]
    [email protected] password:
    bloon@ubuntu:~$

  2. Run as sudo
    bloon@ubuntu:~$sudo su

  3. Run mysql

//-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




Oppsss, mysql-client is not installed yet

  1. Install mysql-client
    root@ubuntu:#apt-get install mysql-client-core-5.1

  2. Run mysql client again
    bloon@ubuntu:#mysql -h 127.0.0.1 -u root -p
    mysql>

  3. Now create user. There are many ways, this the easiest and fastets on mine
    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 ;

Keterangan :
user bego only can be remote from localhost ( bego @ localhost ) dengan akses SU
user bloon can be remote from anywhere( bloon @ % ) dengan akses SU
user ndableg only can be remote from localhost   with limited acces RELOAD dan PROCCESS
user blee only can be accessed from localhost , can not be used yet. Can be added in other time

  1.   Now, u can test user.   Open new terminal tab (ctrl+shift+t)
    root@us-djafa:/home/djafa# mysql -h 192.168.18.131 -u bloon -p
    Enter password:
    Welcome to the MySQL monitor.
    mysql>

Alhamdulillah proses penambahanMySQL user selesai
1. Masuk Server - writer using ubuntu 11.04
#ssh -Y [email protected]

  1. Jalankan sudo secara explicit
    bloon@ubuntu:~$sudo su

  2. Jalankan mysql-client ( Untuk menambah user, anda harus mempunyai user mysql dengan privileges full atau setidaknya menambah user)

Artikel Terkait :  #MySQLTips Menggunakan MySQL Config Editor, cara aman menjalankan MySQL command

//-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

Oppsss, mysql-client is not installed yet

  1. Install mysql-client
    root@ubuntu:#apt-get install mysql-client-core-5.1

  2. Ok, mysql-client sudah dipasang. Sekarang jalankan mysql-client.
    Perintahnya adalah : mysql -h host - u user -p
    bloon@ubuntu:#mysql -h 127.0.0.1 -u root -p
    Welcome to the MySQL monitor.

  3. Jika sudah bisa masuk dengan akses full, sekarang buat user. Ada beberapa cara, namun berikut ini adalah yang penulis anggap paling mudah.
    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 masuk dari localhost ( bego @ localhost ) dengan akses SU
user  bloon bisa masuk dari mana saja  ( bloon @ % ) dengan akses SU
user  ndableg  hanya bisa masuk dari localhost dengan akses terbatas, RELOAD dan PROCCESS
user  blee  hanya bisa di akses dari localhost namun belum diaktifkan. Bisa dilakukan lain waktu
7.  Test user.  Buka 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.
mysql>

Alhamdulillah proses penambahanMySQL user selesai

Jangan lupa tinggalkan komentar ya gais

This site uses Akismet to reduce spam. Learn how your comment data is processed.