Friday, March 26, 2010

How to Install MySQL on Linux?

After spending much time searching on google, blogs, and many others resource I finally found simple way to configure MySQL, here the steps :

1. Login as root and Open terminal then type :

shell> groupadd mysql // to add mysql as a group
shell> useradd -g mysql mysql // add user as mysql
shell> cd /usr/local

// unzip your MySQL source
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -

// make a symbolic link called "mysql"
shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd mysql

// change owner as mysql
shell> chown -R mysql .

// change group as mysql
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql

// change the owner as root
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &

// this is for configure mysql as autorun services
shell> cp mysql.server /etc/init.d/mysql

// this is for changing access type of mysql
shell> chmod +x /etc/init.d/mysql

shell> cd /etc
shell> ln -s rc.d/init.d .

shell> chkconfig --add mysql

shell> chkconfig --level 345 mysql on

2. Setting PATH for MySQL

- open directory /etc/profile and find a file named "profile"

- Edit the file, add this path:

// you can load mysql in any directory
export PATH="$PATH:/usr/local/mysql/bin"

- do a test on terminal as you type mysql -version

3. Set MySQL password:

shell> mysql --user=root mysql
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='agusjuliardi';
mysql> flush privileges; // Untuk reload privileges
mysql> quit

4. Add user MySQL :

// this is for creating a user
mysql> CREATE USER 'agus'@'localhost' IDENTIFIED BY 'some_pass';

// grant all privileges on to user "agus"
mysql> GRANT ALL PRIVILEGES ON *.* TO 'agus'@'localhost' WITH GRANT OPTION;

// create user "agus@%" -> this can be opened on client
mysql> CREATE USER 'agus'@'%' IDENTIFIED BY 'some_pass';

// create user "admin"
mysql> CREATE USER 'admin'@'localhost';

// reload your changes
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';

// create user "dummy"
mysql> CREATE USER 'dummy'@'localhost';

Hopefully Helpful...

No comments:

Post a Comment