First you have to download the required mysql version (eg : mysql-5.6.20)
( http://dev.mysql.com/downloads/mysql/ )
Create user and user group called mysql
Shell> groupadd mysql
Shell> useradd -r -g mysql mysql
Now move the downloaded file (which is gzip compressed) to usr/local from where it is downloaded.
Shell> mv mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz /usr/local (assuming we are in the downloads directory itself)
Change directory to /usr/local
Shell>cd /usr/local
Unpack MySQL
Shell> tar xvfz mysql-5.6.8-rc-linux2.6-x86_64.tar.gz
Rename the directory to mysql and change the path
Shell> mv mysql-5.6.8-rc-linux2.6-x86_64 mysql
Shell> cd mysql
Make the directory owned by the user and group mysql:
Shell> chown -R mysql .
Shell> chgrp -R mysql .
Run
Shell> scripts/mysql_install_db –user=mysql
To create the necessary databases (like the mysql database):
Change some ownerships:
Shell> chown -R root .
Shell> chown -R mysql data
The downloaded MySQL package comes with the init script mysql.server which we copy to /etc/init.d as follows:
Shell> cp support-files/mysql.server /etc/init.d/mysql.server
We can now start MySQL 5.6 as follows:
Shell> /etc/init.d/mysql.server start
To make MySQL start automatically at boot time,
Shell> update-rc.d mysql.server defaults
We cannot call MySQL commands (like mysql,
mysql_secure_installation) without specifying the directory where they are
located (/usr/local/mysql/bin). To call those commands directly those have to
be placed in the PATH (/usr/local/bin), for that we can create symlink as
follows :
ln -s /usr/local/mysql/bin/* /usr/local/bin/
To set root password
mysql_secure_installation
Why user and user
group
Every
process in linux runs under specific user privileges. Services (like
MySQL) usually need to open ports and access various system resources
during startup, so they are required to be started as root user.
However, it is not safe to have all the processes run under root as
it is not required for continuous operation of services, thus it is
recommended to create a special user, which will be used to run MySQL
service. MySQL will only be able to access what special user can, and
this is going to be limited to MySQL files on the system.
mysqld - The MySQL
Server
mysqld,
also known as MySQL Server, is the main program that does most of the
work in a MySQL installation. It manages access to the MySQL data
directory that contains databases and tables. The data directory is
also the default location for other information such as log files and
status files.
mysql_install_db
mysql_install_db
initialize the data directory, including the tables in the mysql
system database. It is a shell script and available only in Linux.You
should either run mysql_install_db from the same system account that
will be used for running mysqld, or run it as root and specify the
--user option to indicate the user name that mysqld will run as.
Shell>
scripts/mysql_install_db --user=mysql
Shell> update-rc.d mysql.server defaults
If defaults is used then update-rc.d will make links to start the service at start-up
What is init.d ?
If
you use Linux, then init.d is one of the most common directories you
have heard of.
But
what is it ??
init.d is the directory that contains number of start/stop scripts for various
services on the system.
Inside
/etc you can find several directories in the form rc#.d (# -
represent any number from 0 to 6, initialization level). Under those
directories there are two type of scripts, that is scripts begin with
'S' or 'K'. All 'K' scripts are run before 'S' scripts. Depending on
where the scripts are located will determine when the scripts
initiate. But when you need to start or stop the processes cleanly
without using “kill” or “killall” commands, that is when
/etc/init.d directory comes in to the play.
To
control any of the init.d scripts manually you need root (or sudo)
access. All those scripts will be run as commands and the structre of
the commands will look like :
/etc/init.d/command
option
Option
can be one of the following :
- start
- stop
- reload
- restart
- force-reload
eg :
Shell> /etc/init.d/mysql.server start
Some
of the common init scripts in this directory are :
- mysql
- networking
- samba - providing support for cross-platform file and printer sharing with Microsoft Windows, OS X, and other Unix
- sshd - Secure Shell, is a protocol used to securely log onto remote systems. It is the most common way to access remote Linux and Unix-like server
Shell> update-rc.d mysql.server defaults
If defaults is used then update-rc.d will make links to start the service at start-up
No comments:
Post a Comment