Install dan Configure MySQL as a non-root user on Linux

Dalam hal ini saya mengalami masalah dimana saya butuh mysql server untuk menyimpan database anope yaitu untuk services irc server, dan ternyata di server yang di tempati licensi cp***** nya sudah habis dan access ke root password databasenya juga lupa, selain itu juga tidak terbukanya akses ke ip public melainkan hanya bisa localhost. pernah coba install lewat account rootnya tapi gagal, disini saya coba lewat access user biasa.

Sebagai praktek saya memakai mesin centos versi CentOS release 4.8. mysql server yang saya install versi  mysql Community Server 5.1.44 .

bisa di download disini:

http://dev.mysql.com/downloads/mysql/#downloads

disini saya memakai directory di /home/x/mysql/

dimana x adalah username saya dan mysql adalah tempat source mysql saya dan nantinya akan saya gunakan untuk iinstalasi saya.

kita extract dahulu

$ tar –zxvf mysql-5.1.44.tar.gz

$ cd mysql-5.1.44

$ CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ; ./configure –prefix=/home/x/mysql –enable-assembler –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-mysqld-user=x –with-unix-socket-path=/home/x/mysql/tmp/mysql.sock –localstatedir=/home/x/mysql/data

 

—- semua perintah di atas harus di tulis satu baris, kemudian kita ketik

untuk detail  configurasinya bisa di baca disini:

http://dev.mysql.com/doc/refman/5.1/en/configure-options.html

$ make; make install

selanjutnya kita masuk ke configurasinya.

$ cd ..

$ export MYSQL_HOME=/home/x/mysql

kita buat file my.cnf

http://dev.mysql.com/doc/refman/5.1/en/option-files.html

saya menggunakan vi editor untuk membuat file my.cnf isinya sebagai berikut

—————————————————————————–

[mysqld]
user=x
basedir=/home/x/mysql
datadir=/home/x/mysql/data
port=7255
socket=/home/x/mysql/tmp/mysql.sock

[mysqld_safe]
log-error=/home/x/mysql/log/mysqld.log
pid-file=/home/x/mysql/mysqld.pid

[client]
port=7255
user=x
socket=/home/x/mysql/tmp/mysql.sock

[mysqladmin]
user=root
port=7255
socket=/home/x/mysql/tmp/mysql.sock

[mysql]
port=7255
socket=/home/x/mysql/tmp/mysql.sock

[mysql_install_db]
user=x
port=7255
basedir=/home/x/mysql
datadir=/home/x/mysql/data
socket=/home/x/mysql/tmp/mysql.sock

—————————–cut here—————————

[x@ mysql]$ bin/mysql_install_db
Installing MySQL system tables…
OK
Filling help tables…
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/home/x/mysql/bin/mysqladmin -u root password ‘new-password’
/home/x/mysql/bin/mysqladmin -u root -h taurus.rodneysg.com password ‘new-password’

Alternatively you can run:
/home/x/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /home/x/mysql ; /home/x/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /home/x/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /home/x/mysql/scripts/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/

[x@ mysql]$

————————-selesai dengan baik—

untuk file my.cnf defaultnya di table berikut:

Filename Purpose
/etc/my.cnf

Global options

/etc/mysql/my.cnf Global options (as of MySQL 5.1.15)
SYSCONFDIR/my.cnf Global options
$MYSQL_HOME/my.cnf Server-specific options
defaults-extra-file The file specified with --defaults-extra-file=path, if any
~/.my.cnf User-specific options

 

file my.cnf di atas kita gunakan yang opsi $MYSQL_HOME/my.cnf

jadi kita perintah

$ export MYSQL_HOME=/home/x/mysql

agar tidak selalu kita setting begitu untuk setiap starup nya maka bisa di masukin ke ~/.bash_profile

supaya bisa otomatis.

langkah selanjutnya menjalankan mysql servernya 😀

[x@ mysql]$ /home/x/mysql/bin/mysqld_safe &
[1] 28452
[x@ mysql]$ 100314 11:39:56 mysqld_safe Logging to ‘/home/x/mysql/log/mysqld.log’.
100314 11:39:57 mysqld_safe Starting mysqld daemon with databases from /home/x/mysql/data

oke sudah jadi. kita test apa bener sudah listen 😛

[x@ mysql]$ telnet localhost 7255
Trying 127.0.0.1…
Connected to localhost (127.0.0.1).
Escape character is ‘^]’.
4
5.1.44"5&[xl6o)yJDT\NU@|t

ot packets out of orderConnection closed by foreign host.
[x@ mysql]$

siiiiip

 

saatnya konfigurasi aksesnya, secara default password root adalah kosong alias tanpa password, maka dari itu kita akan seting :

[x@taurus mysql]$ /home/x/mysql/bin/mysqladmin -u root password ‘password-gue’

 

kita cek aplikasi sudah jalan dengan perintah ps

[x@ mysql]$ ps x
  PID TTY      STAT   TIME COMMAND
19046 ?        S      0:00 sshd: x@pts/1
19053 pts/1    Ss     0:00 -bash
28452 pts/1    S      0:00 /bin/sh /home/x/mysql/bin/mysqld_safe
28540 pts/1    S      0:00 /home/x/mys
ql/libexec/mysqld –basedir=/home/x/mysql –datadir=/home/x/mysql/data –log-error=/home
28541 pts/1    S      0:00 /home/x/mysql/libexec/mysqld –basedir=/home/x/mysql –datadir=/home/x/mysql/data –log-error=/home
28542 pts/1    S      0:00 /home/x/mysql/libexec/mysqld –basedir=/home/x/mysql –datadir=/home/x/mysql/data –log-error=/home
28701 pts/1    R+     0:00 ps x
[x@ mysql]$

ok sudah jadi kan, untuk manage user dan hak aksenya jika merasa kesulitan bisa menggunakan yang versi gui

contohnya saya gunakan navicat bisa juga gunakan mysql front.

nambah user add host allow dan lain sebagainya.

berikut link management nya:

http://dev.mysql.com/doc/refman/5.1/en/account-management-sql.html

http://dev.mysql.com/doc/refman/5.1/en/privilege-system.html

http://dev.mysql.com/doc/refman/5.1/en/environment-variables.html

http://dev.mysql.com/doc/refman/5.1/en/programs.html

————————————————————————————-

sekian pelajaran yang saya dapat hari ini dan berhasil, eski saya pernah coba2 baru bisa malam ini. semoga bisa membantu bagi yang punya masalah seperti saya.

thanks for:

mysql, rhega for the machine, MILDNet, friends, my lovely

untuk semua dukungannya.

Special For my ALLAH thanks GOD untuk nikmat yang telah di berikan.

Administrator

Saya adalah saya, dimana saya tinggal disitu saya berada. Saya suka menulis disela kesibukan saya, tapi saat sibuk saya tidak bisa menyempatkan waktu untuk menulis.

Leave a Reply

Your email address will not be published. Required fields are marked *