Installing MySQL from a tarball
Installing MySQL from a tarball should be straightforward but there are several steps, and therefore several opportunities for things to get funky. Nonetheless, doing it this way you will learn more about several aspects of your system, and what's really going on with the installation, and you'll see all the work that you'd save by using rpm.Installing things from tarballs is a common practice on UNIX/Linux systems. You'll be doing it later when you install DBI as well. By then you'll be a pro. It usually involves just a few simple steps. Tarballs usually come as compressed, tar'd files. tar stands for Tape Archive, and refers to a format for storing and archiving files and directory structures. When you unpack a tar ball it recreates the original directory structure and files.
The binary source tarball comes with everything you need to run MySQL, as well as all the client programs for interacting with the database, and the development libraries for writing or using your own programs with the database. To install the software you should be able to log into your system as root. By default, mysql would run as a root process, and some of the files would be owned by root. Because this is something of a security risk, many people choose to create a regular user for running the mysql deamon. This way there are less root owned files on your system, and fewer opportunities for exploiting a root owned process. Once you have the software, and created a user, you can install the database and start it up. The last steps are simply to set an administration password, and then modify your system so that it starts the mysql deamon everytime the system is started.
Installation Overview
Basically you'll be performing the following steps:- Get the tarball
- decompress and unpack the tarball
- create a symbolic link to the mysql directory
- create a user whose ID is used for running the database
- change ownership of the directory from root to user mysql
- edit the init startup file
- su to user mysql
- initialize the database and create the tables with the included install script
- start the database
- change the root password
- change back to user root
- place startup file in proper startup location
Get the software and unpack it
The tarball is more formally called a binary source distribution. You can get the source distribution at the same place you get the rpm files: www.mysql.com. It will have some filename like: mysql-3.22.32-pc-linux-gnu-i686.tar.gzA common place to install software on linux systems is in the directory:
/usr/local/
Once you have the software, log in as root and move the tarball to that directory. The filename of the software will have two extenions on the end: .tar.gz The gz indicates that the file is compressed. To uncompress the file issue the command:
gunzip filename.tar.gz
this will decompress the file and remove the .gz extension. Now you have a true tar file. Unpack it using the tar command with the appropriate arguments:
tar -xvf filename.tar
the x means extract, the v means verbose (show me everything that's happening), and the f indicates that the next argument is the filename to extract. You should see the names of files and directories wizzing by your screen. If you list the contents of the current directory you should see that a new directory containing all the mysql files has been created.
Now that you have the distribution unpacked, it's a good idea to create the user that will own the files and run the database. You can do this with the adduser command.
Since it has a long clunky name, you should create a symbolic link to it (the same thing as an alias or shortcut):
Create a user for the mysql program
From a security point of view you'd like to run the server as some user other than root. It's also a good idea to not have any more root-owned files lying around your system than are necessary. To accomplish this you can simply create a user and group for owning and running the server. I create a user called mysql, with no home directory. We do this with the adduser and groupadd commands./usr/sbin/groupadd mysql #create the user mysql with no home directory and group mysql /usr/sbin/adduser mysql -M -g mysql
Now su to user mysql and initialize your database tables. It's
important to do this as the user mysql, because otherwise the tables
and directories will be created as owned by root
[root@zenith mysql]#su mysql [mysql@zenith mysql]# [mysql@zenith mysql]# scripts/mysql_install_db Creating db table Creating host table Creating user table Creating func table Creating tables_priv table Creating columns_priv table 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 ! This is done with: ./bin/mysqladmin -u root password 'new-password' See the manual for more instructions. Please report any problems with the ./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://www.tcx.se/license.htmy. [mysql@zenith mysql-3.22.32-pc-linux-gnu-i686]# |
Now before you can set the root password, you must start the mysqld daemon. This is done with a little script in the scripts directory called safe_mysqld.
[root@zenith mysql-3.22.32-pc-linux-gnu-i686]# bin/safe_mysqld & [1] 1541
# Starting mysqld daemon with databases from /usr/local/mysql-3.22.32-pc-linux-gnu-i686/data
[root@zenith mysql-3.22.32-pc-linux-gnu-i686]You can see if the daemon is running by looking at all the system process:
ps aux | more
Now try setting the root password:
[root@zenith mysql-3.22.32-pc-linux-gnu-i686]# ./bin/mysqladmin -u root password 'friday' |
[root@zenith mysql-3.22.32-pc-linux-gnu-i686]# bin/mysql -pfriday mysql> show databases; +----------+ | Database | +----------+ | mysql | | test | +----------+ 2 rows in set (0.00 sec) mysql> |
Set the mysql daemon to start at system start up
Next we have to make it so that the mysql server will start up everytime the computer is started. This is accomplished by a script that holds information about how the server should be started. We need to edit that script and place it in the proper location for system start up. There's a place onthe system for start up files edit support-files/mysql.server and change user to mysql[root@zenith support-files]# cp mysql.server mysql.server-dist [root@zenith support-files]# emacs -nw mysql.server [root@zenith support-files]# cp mysql.server /etc/rc.d/init.d/ [root@zenith support-files]# cd /etc/rc.d/init.d/ [root@zenith init.d]# chmod a+x mysql.server [root@zenith init.d]# ls -al mysql.server -rwxrwxr-x 1 root root 2815 Oct 9 2000 mysql.serverWhen your system starts up there is a series of things in rc.d directory that occur. To add mysql as one of the things that gets started use the chkconfig command. Type: man chkconfig for more information on this. Or continuing from above, issue the following comands:
[root@zenith init.d]# /sbin/chkconfig --add mysql.server [root@zenith init.d]# /sbin/chkconfig --list mysql.server mysql.server 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@zenith init.d]#The first command "chkconfig --add" adds the proper links in the right places for your system to execute the mysql.server script upon system startup. The second command "chkconfig --list" reports back to you the run levels in which the script is executed.
It's also a good idea to add the path to the mysql bin directory to the default path of users.
MySQL Internals, MySQL HighAvailability, MySQL Performance Tuning, MySQL Query Optimization, MySQL performance, MySQL Fabric, MySQL HA, MySQL Installation, MySQL Upgrade, InnoDB Performance Tuning, InnoDB Buffer Pool Size, MySQL Performance Tuning, MySQL ClusterMySQL Latest News, News and Events, MySQL Customers
No comments:
Post a Comment