Tujuan utama blog ini diwujudkan ialah untuk mengingatkan diri sendiri melalui nota dan catatan ringkas, pengalaman menyelesaikan isu-isu dan langkah-langkah yang berkaitan dalam penggunaan sistem operasi sumber terbuka. Selain itu adalah diharapkan blog ini dapat membantu pelatih, rakan dan siapa saja yang berminat dalam penggunaan perisian sumber terbuka terutama dalam pendidikan dan khususnya dalam pendidikan keguruan.
Selasa, 10 Julai 2012
Memasang MySQL pada CentOS 6.3
Dah pasang mysql? Memasang mysql pada CentOS 6.3
Langkah 1 - Semak sama ada MySQL telah dipasang:
[root@oll-new /]# mysql
-bash: mysql: command not found
Langkah 2 - Pasang MySQL dengan sokongan untuk php:
[root@oll-new /]# yum install mysql php-mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.mel.bkb.net.au
* extras: centos.ipserverone.com
* updates: centosg4.centos.org
Setting up Install Process
Package php-mysql-5.3.3-14.el6_3.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.61-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
mysql x86_64 5.1.61-4.el6 base 882 k
Transaction Summary
========================================================================================================
Install 1 Package(s)
Total download size: 882 k
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
mysql-5.1.61-4.el6.x86_64.rpm | 882 kB 00:09
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-5.1.61-4.el6.x86_64 1/1
Verifying : mysql-5.1.61-4.el6.x86_64 1/1
Installed:
mysql.x86_64 0:5.1.61-4.el6
Complete!
Langkah 3 - Pasang mysql-server:
[root@oll-new /]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.mel.bkb.net.au
* extras: centos.ipserverone.com
* updates: centosg4.centos.org
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.61-4.el6 will be installed
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.61-4.el6.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.61-4.el6.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.61-4.el6.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
mysql-server x86_64 5.1.61-4.el6 base 8.6 M
Installing for dependencies:
perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k
perl-DBI x86_64 1.609-4.el6 base 705 k
Transaction Summary
========================================================================================================
Install 3 Package(s)
Total download size: 9.4 M
Installed size: 27 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): mysql-server-5.1.61-4.el6.x86_64.rpm | 8.6 MB 01:46
(2/3): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:01
(3/3): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:09
--------------------------------------------------------------------------------------------------------
Total 81 kB/s | 9.4 MB 01:58
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-DBI-1.609-4.el6.x86_64 1/3
Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 2/3
Installing : mysql-server-5.1.61-4.el6.x86_64 3/3
Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/3
Verifying : mysql-server-5.1.61-4.el6.x86_64 2/3
Verifying : perl-DBI-1.609-4.el6.x86_64 3/3
Installed:
mysql-server.x86_64 0:5.1.61-4.el6
Dependency Installed:
perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6
Complete!
Langkah 4 - Pasang mysql-devel:
[root@oll-new /]# yum install mysql-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.mel.bkb.net.au
* extras: centos.ipserverone.com
* updates: centosg4.centos.org
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-devel.x86_64 0:5.1.61-4.el6 will be installed
--> Processing Dependency: openssl-devel for package: mysql-devel-5.1.61-4.el6.x86_64
--> Running transaction check
---> Package openssl-devel.x86_64 0:1.0.0-20.el6_2.5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
mysql-devel x86_64 5.1.61-4.el6 base 127 k
Installing for dependencies:
openssl-devel x86_64 1.0.0-20.el6_2.5 base 1.1 M
Transaction Summary
========================================================================================================
Install 2 Package(s)
Total download size: 1.3 M
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): mysql-devel-5.1.61-4.el6.x86_64.rpm | 127 kB 00:01
(2/2): openssl-devel-1.0.0-20.el6_2.5.x86_64.rpm | 1.1 MB 00:15
--------------------------------------------------------------------------------------------------------
Total 70 kB/s | 1.3 MB 00:18
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : openssl-devel-1.0.0-20.el6_2.5.x86_64 1/2
Installing : mysql-devel-5.1.61-4.el6.x86_64 2/2
Verifying : openssl-devel-1.0.0-20.el6_2.5.x86_64 1/2
Verifying : mysql-devel-5.1.61-4.el6.x86_64 2/2
Installed:
mysql-devel.x86_64 0:5.1.61-4.el6
Dependency Installed:
openssl-devel.x86_64 0:1.0.0-20.el6_2.5
Complete!
You have new mail in /var/spool/mail/root
Langkah 5 - Mulakan daemon MySQL (mysqld):
[root@oll-new /]# chkconfig --level 2345 mysqld on; service mysqld start
Initializing MySQL database: WARNING: The host 'oll-new' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
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:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h oll-new password 'new-password'
Alternatively you can run:
/usr/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 /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@oll-new /]#
Langkah 6 - Login sebagai root pentadbir pangkalan pelayan MySQL:
[root@oll-new /]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.61 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Langkah 7 - Hapus semua pengguna yang bukan root:
mysql> delete from mysql.user where not (host="localhost" and user="root");
Query OK, 4 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Langkah 8 - Ubah kata laluan root pentadbir pangkalan data:
mysql> set password for 'root'@'localhost' = password('rahsia');
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Langkah 9 - Ubah pengguna root untuk tingkat keselamatan:
mysql> update mysql.user set user="mydbadmin" where user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
Langkah 10 - Halang capaian secara anonymous kepada pangkalan data:
mysql> delete from mysql.user where User='';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
Langkah 11 - Untuk pastikan mysql dan pelayan mysql telah dipasang dengan versi yang betul:
[root@oll-new /]# rpm -qa | grep mysql && chkconfig --list | grep mysql
mysql-server-5.1.61-4.el6.x86_64
mysql-libs-5.1.61-4.el6.x86_64
mysql-5.1.61-4.el6.x86_64
php-mysql-5.3.3-14.el6_3.x86_64
mysql-devel-5.1.61-4.el6.x86_64
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Langkah 12 - Mulakan mysqld apabila boot:
[root@oll-new /]# chkconfig --level 2345 mysqld on && service mysqld restart && chkconfig --list | grep mysqld
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off