installing mysql on linux

You can install mysql using the following methods

  • Installing mysql from Source tar.gz files
  • Installing mysql from Binary .rpm file, either
    • from CD, or
    • using yum utility
  • You can select to install mysql during Linux Installation Setup

But I would recommend you to Compile and install it from source files, as you can compile it using your own settings (include or exclude options).

Installing from CD

If you want to install the binaries, you can do it using the rpm files included in the Linux CD, search for mysql binaries in the CD, and install mysql-5.0.22-2.1.i386.rpm , mysql-devel-5.0.22-2.1.i386.rpm and mysql-server-5.0.22-2.1.i386.rpm

[root@localhost RPMS]# rpm -ivh mysql-5.0.22-2.1.i386.rpm
warning: mysql-5.0.22-2.1.i386.rpm: Header V3
 DSA signature: NOKEY, key ID 4f2a6fd2
Preparing…                ########################################### [100%]
   1:mysql                  ########################################### [100%]
[root@localhost RPMS]#

[root@localhost RPMS]# rpm -ivh mysql-devel-5.0.22-2.1.i386.rpm

[root@localhost RPMS]# rpm -ivh mysql-server-5.0.22-2.1.i386.rpm

Installing mysql using yum utility

If You want to install mysql using yum utility, try

[root@localhost ~]# yum install mysql

[root@localhost ~]# yum install mysql-devel

[root@localhost ~]# yum install mysql-server

Auto start mysql at boot

[root@localhost ~]#chkconfig –levels 235 mysqld on

Start mysql

[root@localhost ~]# /etc/init.d/mysqld start

Starting MySQL                                             [  OK ]

[root@localhost ~]#

mysql should start listening on port 3306

[root@localhost ~]# netstat -ntlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address      Foreign Address  State   PID/Program
tcp        0      0 127.0.0.1:2208     0.0.0.0:*        LISTEN  2016/hpiod
tcp        0      0 127.0.0.1:38081    0.0.0.0:*        LISTEN  2021/python
tcp        0      0 0.0.0.0:3306     0.0.0.0:*         LISTEN      4247/mysqld
tcp        0      0 0.0.0.0:111        0.0.0.0:*        LISTEN  1828/portmap
tcp        0      0 0.0.0.0:757        0.0.0.0:*        LISTEN  1847/rpc.statd
tcp        0      0 127.0.0.1:631      0.0.0.0:*        LISTEN  2031/cupsd
tcp        0      0 :::22              :::*             LISTEN  2040/sshd
tcp        0      0 ::1:631            :::*             LISTEN  2031/cupsd

change the root password

[root@localhost ~]# mysqladmin -u root password yourownpassword

Remember, this password is different than root login password

Installing mysql from Source file

Now we’ll download the source file using wget command, configure it, compile it and install it into /usr/local/mysql. so lets download the file from http://mirror.provenscaling.com/mysql/community/source/5.1/. Select file mysql-5.1.22-rc.tar.gz to download

[root@localhost src]# wget http://mirror.provenscaling.com/mysql/community/
source/5.1/mysql-5.1.22-rc.tar.gz
–01:03:18–  http://mirror.provenscaling.com/mysql/community/source/5.1/my
sql-5.1.22-rc.tar.gz
Resolving mirror.provenscaling.com… 64.34.251.130
Connecting to mirror.provenscaling.com|64.34.251.130|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 28662040 (27M) [application/x-gzip]
Saving to: `mysql-5.1.22-rc.tar.gz’100%[====================================================
=========================================================
=======>] 28,662,040   238K/s   in 1m 59s
01:05:18 (236 KB/s) - `mysql-5.1.22-rc.tar.gz’ saved [28662040/28662040]
[root@localhost src]#

now extract the files from .tar.gz,

[root@localhost src]# tar -xvzf mysql-5.1.22-rc.tar.gz

We’ll make a group ‘mysql’ and add a user ‘mysql’ to ‘mysql’ group. Later on we’ll give permissions to mysql user to own & run mysql for security purpose.

[root@localhost src]#addgroup mysql

[root@localhost src]#useradd -g mysql  mysql

Configure it to be install in /usr/local/mysql directory using the user mysql, you can check other options using ./configure -h

[root@localhost src]# ./configure \
–prefix=/usr/local/mysql \
–localstatedir=/usr/local/mysql/data \
–with-mysqld-user=mysql \

now compile and install mysql

[root@localhost src]# make

[root@localhost src]# make install

It will take some time to complete depends on system specs, wait and let it complete. After it successfully installed, the the script mysql_install_db to install mysql database

[root@localhost src]# mysql_install_db

[root@localhost src]# chown -R root:mysql /usr/local/mysql
[root@localhost src]# chown -R mysql:mysql /usr/local/mysql/data
[root@localhost ~]#chkconfig –levels 235 mysqld on
[root@localhost ~]#/etc/rc.d/init.d/mysql start
[root@localhost ~]# mysqladmin -u root password yourownpassword

Check mysql and create a test database

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.22-rc-log Source distribution
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> create database compwrite;
Query OK, 1 row affected (0.00 sec)
mysql>

I hope this helps you, please correct me if i’m wrong. Any suggestions/critics/comments will be much prevaricated. Thanks in advanced


3 Responses to “installing mysql on linux

Leave a Reply