Installing MySQL from a tarball
来源:互联网 发布:php 权限拦截器 编辑:程序博客网 时间:2024/04/30 07:48
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 addusercommand.
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 mysqlNow 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 tableCreating host tableCreating user tableCreating func tableCreating tables_priv tableCreating columns_priv tableTo start mysqld at boot time you have to copy support-files/mysql.serverto the right place for your systemPLEASE 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.comSupport 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[root@zenith mysql-3.22.32-pc-linux-gnu-i686]# Starting mysqld daemon with databases from /usr/local/mysql-3.22.32-pc-linux-gnu-i686/data
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'
You can also try connecting to the server and issuing a command:
[root@zenith mysql-3.22.32-pc-linux-gnu-i686]# bin/mysql -pfridaymysql> 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.servermysql.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.
- Installing MySQL from a tarball
- Installing from a distribution package
- ubuntu / Installing MySQL 5.6.x from source
- Installing MySQL from Source on Windows
- Installing and Configuring a MySQL Database
- ROS Installing from source
- Installing TensorFlow from Sources
- 官网 Mysql Installing MySQL on Linux Using RPM Packages from Oracle
- Have you tried doing a complete uninstall (from registry) and re-installing ADI?
- Installing Perl modules from CPAN
- Installing from Source Under Ubuntu
- Installing a Service
- Installing a package yourself
- Installing a USB Driver
- Installing MySQL on Solaris
- Debian Lenny - Installing MySQL
- installing debian from a usb stick with windows(在windows下,从U盘安装debian系统)
- 手动打包sun java jdk [Installing the latest JDK on Debian by creating a .deb package from Sun binaries]
- 提高你开发效率的十五个Visual Studio 2010使用技巧
- sys_connect_by_path 的用法
- 关于迷途指针
- mmc子系统学习笔记八 详谈如何构造mmc_card设备
- Tomcat学习笔记(一)
- Installing MySQL from a tarball
- 低端手机这个野百合在新技术的推动下也会有春天
- unicode点阵字模生成工具生成32*32字库在bootloader中显示的代码
- java.nio.ByteBuffer 以及flip,clear及rewind区别
- Tika是什么?如何安装Tika?
- 定制Android关机界面
- commons-BeanUtils简介
- 正则表达式 java和js区别
- performace evoluation in tracking object in the video sequence