Main Contents

tips and tricks on installing mysql

31 August 2007

Fyuuh.. this is my first tutorial of mysql, lets get start

First you have to decide what platform do you have on your system, is it Windows or Unix. Then get the installer package for the latest mysql distribution on mysql.org that fit on your OS platform.

In windows you can choose the the windows ZIP/Setup.exe or the without installer (Zip it on your C:\ ) . On Unix, you can choose that fit on your Linux distribution or your BSD (FreeBSD). For me, i choose the without installer for my Windows (XP) and the FreeBSD package for my Unix.

Windows XP:

  • After you zipped the zip file on C:\ change the default name folder to C:\mysql
  • Use the command promt then go to C:\mysql\bin\
  • Type mysqld –install to install the mysql as a service
  • Then go the administrative tools (Start - Control Panel - Administrative Tools) the select the services , choose the mysql service then start it to run the service

FreeBSD or other Unix OS:

  • After you download the mysql-*.tar.gz put it somewhere on your sistem then do this following (example: /usr/local/mysql) .
  • tar xzvf mysql-*.tar.gz (you can use gunzip or other)
  • cd mysql-* (enter the folder that you’ve zipped)
  • groupadd mysql
  • useradd -g mysql mysql
  • chown -R mysql .
  • chgrp -R mysql .
  • scripts/mysql_install_db –user=mysql
  • chown -R root .
  • chown -R mysql data
  • bin/mysqld_safe –user=mysql & (to start the service)

If you want to run the mysql service on boot process, type vi /etc/rc.d/mysql.sh then write this following script:
echo -n "Starting the mysql service";
/usr/local/mysql/bin/mysqld_safe --user=mysql &

then save it.

The Installation is finished. Now we need to add the root password and add a new user that have less previlege than the root to prevent somebody to use blank password on root login and limit the application that using the database user login (do not give the root user to application that using our mysql database to limit the privilege if someone success to break the application and get the user privilege). Do this following:

  • Login as root (on unix) and go to the bin folder then type mysql , then you will login as root@localhost with blank password, then type the following
  • use mysql; (to select the mysql database)
  • select host, user, password from user; (to view the list of the users, host, anda their password)

The Command will views like this:

+————————+——+———-+
| host | user | password |
+————————+——+———-+
| localhost | root | |
| localhost.localdomain | root | |
+————————+——+———-+
2 rows in set (0.00 sec)

  • As you can see, the root password is blank. We need to fill out the root password, then type this following
  • update user set password=password(’your_password’) where user = ‘root’;
  • The command will change the root password, to view the change use the select command again.

The Command will views like this:

mysql> select host,user,password from user;
+———————–+——+——————+
| host | user | password |
+———————–+——+——————+
| localhost | root | 2b50114e7dd56ee6 |
| localhost.localdomain | root | 2b50114e7dd56ee6 |
+———————–+——+——————+
2 rows in set (0.01 sec)

  • As you can see, the password is encrypted.. :D
  • Then load the user last change by typing this
  • flush privileges;
  • Then exit form mysql by typing exit then try to login again by typing
  • mysql -u root -p (to login as root)
  • Enter the root password.

Now we have a mysql root user with password to login. Then we will add a user with limited privileges. Do this following:

  • insert into user set user=’user_name’, host=’%', password=password(’password’), select_priv=’Y', update_priv=’Y', delete_priv=’Y', insert_priv=’Y';
  • flush privileges;
  • Use the command select again to view the new user.

The command above will add a user with 4 privileges (select, update, delete, and insert) are enabled and other privileges were disabled (find out about other privileges on mysql user).

We use host=’%’ so we can access the mysql database with this user login anywhere (root must be on limited access host) for application used.

That’s all for this tutorial, i hope this usefull… :)

Detail: belajar |

Satu Komentar to “tips and tricks on installing mysql”

  1. dark_ipl
    1
    Komentar Penulis

    bahasa inggrisku belepotan.. :cd:

    Balas Komentar Ini

Beri Komentar

:) :( :d :"> :(( \:d/ :x 8-| /:) :o :-? :-" :-w :doh: :yosh: :dance: semua »