Installation of MySql on CentOS 5.1
The Scenario
One of the server in the office went kaput due to hard disk failure. Not bad for a Western Digital 80G which was bought somewhere back the year 2000 (7 years). Unfortunately, all previous data was unrecoverable and I am forced to get a new hard disk drive and start a fresh install. I chose CentOS 5.1
Before I fired up Filezilla to start the download, I have a question on how long this download will take since the average file size is around 600MB and there are 6 ISOs a total of 3GB. With 1MB streamyx probably could take up 2 to 3 days. That’s not productive.
I managed to use one of our restricted server in Jaring datacenter (with permission) to do the download of all 6 ISOs in just around 7 minutes! Then, it took half day to download all ISOs from Jaring to our office. So I think, not bad.

Installation is not difficult guided by the GUI and pretty straightforward. Even a 10 years old kid with good English language (I am talking about Malaysian kids) and the ability to use google.com will certainly able to do it. Now, the challenge is to put things together.
There are few things to configure immediately based on the sole purpose of the server which is as a release server. A release server is where all requirement of project which are completed and the client will need to test/verify/debug/etc took place. This is important before we replace the client live site with the most updated one. These are the things I need to configure:
- Samba
- Apache
- MySQL
- PHP
We use Samba to share files between Linux file system and Windows file system. Apache is a web server software. MySQL is a low adoption costs associated with open-source RDBMS. PHP is a server-side HTML embedded scripting language
The Real Deal
In this article, I will only cover MySQL installation and configuration based on my experience. This interesting because the MySQL server is not installed by default. Most of the time, people will get error when trying to connect to MySQL. I will cover Apache and PHP next time. Let’s get started:
[root@langkung conf]# mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
This is the error when I tried to connect to MySQL
[root@langkung conf]# rpm -q mysql mysql-5.0.22-2.2.el5_1.1
I want to know if mysql server was installed. In this case, no.
[root@langkung conf]# yum --enablerepo=centosplus install mysql-server Loading "installonlyn" plugin Setting up Install Process Setting up repositories Reading repository metadata in from local files Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for mysql-server to pack into transaction set. mysql-server-5.0.22-2.2.e 100% |=========================| 33 kB 00:01 ---> Package mysql-server.i386 0:5.0.22-2.2.el5_1.1 set to be updated --> Running transaction check --> Processing Dependency: perl-DBD-MySQL for package: mysql-server --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for perl-DBD-MySQL to pack into transaction set. perl-DBD-MySQL-3.0007-1.f 100% |=========================| 8.3 kB 00:00 ---> Package perl-DBD-MySQL.i386 0:3.0007-1.fc6 set to be updated --> Running transaction check Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: mysql-server i386 5.0.22-2.2.el5_1.1 updates 10 M Installing for dependencies: perl-DBD-MySQL i386 3.0007-1.fc6 base 147 k Transaction Summary ============================================================================= Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 10 M Is this ok [y/N]: y Downloading Packages: (1/2): perl-DBD-MySQL-3.0 100% |=========================| 147 kB 00:03 (2/2): mysql-server-5.0.2 100% |=========================| 10 MB 02:41 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: perl-DBD-MySQL ######################### [1/2] Installing: mysql-server ######################### [2/2] Installed: mysql-server.i386 0:5.0.22-2.2.el5_1.1 Dependency Installed: perl-DBD-MySQL.i386 0:3.0007-1.fc6 Complete!
Install MySQL server through yum
[root@langkung conf]# chkconfig --list | grep mysql
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@langkung conf]# chkconfig --help
chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.
usage: chkconfig --list [name]
chkconfig --add <name>
chkconfig --del <name>
chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities>
[root@langkung conf]# chkconfig --level 235 mysqld on
[root@langkung conf]# chkconfig --list | grep mysql
mysqld 0:off 1:off 2:on 3:on 4:off 5:on 6:offRegister mysqld into ’service’ so that mysqld will be started everytime the server reboot.
[root@langkung conf]# service mysqld start
Initializing MySQL database: Installing all prepared tables
Fill help tables
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 langkung password 'new-password'
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 the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[ OK ]
Starting MySQL: [ OK ]
[root@langkung conf]#Start the MySQL server
[root@langkung conf]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 5.0.22 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
Login to MySQL console. At this point, no root password is set so I just press enter when prompted with password
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows IN SET (0.00 sec) mysql> USE mysql; Reading table information for completion of table AND COLUMN names You can turn off this feature to get a quicker startup with -A Database changed mysql> SHOW TABLES; +---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | db | | func | | help_category | | help_keyword | | help_relation | | help_topic | | host | | proc | | procs_priv | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 17 rows IN SET (0.01 sec) mysql> DESCRIBE user; +-----------------------+-----------------------------------+------+-----+---------+-------+ | FIELD | Type | NULL | Key | DEFAULT | Extra | +-----------------------+-----------------------------------+------+-----+---------+-------+ | Host | CHAR(60) | NO | PRI | NULL | | | User | CHAR(16) | NO | PRI | NULL | | | Password | CHAR(41) | NO | | NULL | | | Select_priv | ENUM('N','Y') | NO | | N | | | Insert_priv | ENUM('N','Y') | NO | | N | | | Update_priv | ENUM('N','Y') | NO | | N | | | Delete_priv | ENUM('N','Y') | NO | | N | | | Create_priv | ENUM('N','Y') | NO | | N | | | Drop_priv | ENUM('N','Y') | NO | | N | | | Reload_priv | ENUM('N','Y') | NO | | N | | | Shutdown_priv | ENUM('N','Y') | NO | | N | | | Process_priv | ENUM('N','Y') | NO | | N | | | File_priv | ENUM('N','Y') | NO | | N | | | Grant_priv | ENUM('N','Y') | NO | | N | | | References_priv | ENUM('N','Y') | NO | | N | | | Index_priv | ENUM('N','Y') | NO | | N | | | Alter_priv | ENUM('N','Y') | NO | | N | | | Show_db_priv | ENUM('N','Y') | NO | | N | | | Super_priv | ENUM('N','Y') | NO | | N | | | Create_tmp_table_priv | ENUM('N','Y') | NO | | N | | | Lock_tables_priv | ENUM('N','Y') | NO | | N | | | Execute_priv | ENUM('N','Y') | NO | | N | | | Repl_slave_priv | ENUM('N','Y') | NO | | N | | | Repl_client_priv | ENUM('N','Y') | NO | | N | | | Create_view_priv | ENUM('N','Y') | NO | | N | | | Show_view_priv | ENUM('N','Y') | NO | | N | | | Create_routine_priv | ENUM('N','Y') | NO | | N | | | Alter_routine_priv | ENUM('N','Y') | NO | | N | | | Create_user_priv | ENUM('N','Y') | NO | | N | | | ssl_type | ENUM('','ANY','X509','SPECIFIED') | NO | | NULL | | | ssl_cipher | BLOB | NO | | NULL | | | x509_issuer | BLOB | NO | | NULL | | | x509_subject | BLOB | NO | | NULL | | | max_questions | INT(11) UNSIGNED | NO | | 0 | | | max_updates | INT(11) UNSIGNED | NO | | 0 | | | max_connections | INT(11) UNSIGNED | NO | | 0 | | | max_user_connections | INT(11) UNSIGNED | NO | | 0 | | +-----------------------+-----------------------------------+------+-----+---------+-------+ 37 rows IN SET (0.00 sec) mysql> SELECT Host, User, Password FROM user; +-----------+------+----------+ | Host | User | Password | +-----------+------+----------+ | localhost | root | | | langkung | root | | | langkung | | | | localhost | | | +-----------+------+----------+ 4 rows IN SET (0.00 sec) mysql> UPDATE user SET Password = PASSWORD('localdbroot') WHERE Host = 'localhost' AND user = 'root' LIMIT 1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 WARNINGS: 0 mysql> UPDATE user SET Password = PASSWORD('localdbroot') WHERE Host = 'langkung' AND user = 'root' LIMIT 1; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 WARNINGS: 0 mysql> DELETE FROM user WHERE Host = 'langkung' AND User = '' AND Password = '' LIMIT 1; Query OK, 1 row affected (0.01 sec) mysql> DELETE FROM user WHERE Host = 'localhost' AND User = '' AND Password = '' LIMIT 1; Query OK, 1 row affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> SELECT Host, User, Password FROM user; +-----------+------+------------------+ | Host | User | Password | +-----------+------+------------------+ | localhost | root | 3c4c3f7b36430424 | | langkung | root | 3c4c3f7b36430424 | +-----------+------+------------------+ 2 rows IN SET (0.00 sec) mysql> exit Bye [root@langkung conf]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands END with ; OR \g. Your MySQL connection id IS 3 to server version: 5.0.22 Type 'help;' OR '\h' for HELP. Type '\c' to clear the buffer. mysql> exit Bye [root@langkung conf]#
Change the mysql root password and verifiy
Conclusion
There is really nothing special about all the above steps. This is just my own notes so that probably when I’m at client site I might need this. Who knows. Another thing is, there could be other simple steps then the one I went through and I am looking forward for update/correction.
1 Comment
Jump to comment form | comments rss [?] | trackback uri [?]