Installing MySQL on Unix/Linux Using Generic Binaries

 Installing MySQL on Unix/Linux Using Generic Binaries

Oracle provides a set of binary distributions of MySQL. These include generic binary distributions in the form of compressed tar files (files with a .tar.gz extension) for a number of platforms, and binaries in platform-specific package formats for selected platforms.

This section covers the installation of MySQL from a compressed tar file binary distribution on Unix/Linux platforms. For other platform-specific binary package formats, see the other platform-specific sections in this manual. For example, for Windows distributions, see Section 2.3, “Installing MySQL on Microsoft Windows”. See Section 2.1.2, “How to Get MySQL” on how to obtain MySQL in different distribution formats.

MySQL compressed tar file binary distributions have names of the form mysql-VERSION-OS.tar.gz, where VERSION is a number (for example, 5.6.44), and OS indicates the type of operating system for which the distribution is intended (for example, pc-linux-i686 or winx64).

Warning

If you have previously installed MySQL using your operating system native package management system, such as Yum or APT, you may experience problems installing using a native binary. Make sure your previous MySQL installation has been removed entirely (using your package management system), and that any additional files, such as old versions of your data files, have also been removed. You should also check for configuration files such as /etc/my.cnf or the /etc/mysql directory and delete them.

For information about replacing third-party packages with official MySQL packages, see the related APT guide or Yum guide.

Warning

MySQL has a dependency on the libaio library. Data directory initialization and subsequent server startup steps will fail if this library is not installed locally. If necessary, install it using the appropriate package manager. For example, on Yum-based systems:

shell> yum search libaio  # search for info
shell> yum install libaio # install library

Or, on APT-based systems:

shell> apt-cache search libaio # search for info
shell> apt-get install libaio1 # install library
 

To install a compressed tar file binary distribution, unpack it at the installation location you choose (typically /usr/local/mysql). This creates the directories shown in the following table.

Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package

DirectoryContents of Directory
bin, scriptsmysqld server, client and utility programs
dataLog files, databases
docsMySQL manual in Info format
includeInclude (header) files
libLibraries
mysql-testTest suite
manUnix manual pages
shareError messages, dictionary, and SQL for database installation
sql-benchBenchmarks
support-filesMiscellaneous support files, including sample configuration files
 

 

Note

SLES 11: as of MySQL 5.6.37, the Linux Generic tarball package format is EL6 instead of EL5. As a side effect, the MySQL client bin/mysql needs libtinfo.so.5.

A workaround is to create a symlink, such as ln -s libncurses.so.5.6 /lib64/libtinfo.so.5 on 64-bit systems or ln -s libncurses.so.5.6 /lib/libtinfo.so.5 on 32-bit systems.

Debug versions of the mysqld binary are available as mysqld-debug. To compile your own debug version of MySQL from a source distribution, use the appropriate configuration options to enable debugging support. See Section 2.9, “Installing MySQL from Source”.

To install and use a MySQL binary distribution, the command sequence looks like this:

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
Note

This procedure assumes that you have root (administrator) access to your system. Alternatively, you can prefix each command using the sudo (Linux) or pfexec (Solaris) command.

Note

The procedure does not assign passwords to MySQL accounts. To do so, use the instructions in Section 2.10.4, “Securing the Initial MySQL Accounts”.

As of MySQL 5.6.8, mysql_install_db creates a default option file named my.cnf in the base installation directory. This file is created from a template included in the distribution package named my-default.cnf. For more information, see Section 5.1.2.2, “Using a Sample Default Server Configuration File”.

A more detailed version of the preceding description for installing a binary distribution follows.

Create a mysql User and Group

If your system does not already have a user and group to use for running mysqld, you may need to create them. The following commands add the mysql group and the mysql user. You might want to call the user and group something else instead of mysql. If so, substitute the appropriate name in the following instructions. The syntax for useradd and groupadd may differ slightly on different versions of Unix/Linux, or they may have different names such as adduser and addgroup.

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
Note

Because the user is required only for ownership purposes, not login purposes, the useradd command uses the -r and -s /bin/false options to create a user that does not have login permissions to your server host. Omit these options if your useradd does not support them.

Obtain and Unpack the Distribution

Pick the directory under which you want to unpack the distribution and change location into it. The example here unpacks the distribution under /usr/local. The instructions, therefore, assume that you have permission to create files and directories in /usr/local. If that directory is protected, you must perform the installation as root.

shell> cd /usr/local

Obtain a distribution file using the instructions in Section 2.1.2, “How to Get MySQL”. For a given release, binary distributions for all platforms are built from the same MySQL source distribution.

Unpack the distribution, which creates the installation directory. tar can uncompress and unpack the distribution if it has z option support:

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

The tar command creates a directory named mysql-VERSION-OS.

To install MySQL from a compressed tar file binary distribution, your system must have GNU gunzip to uncompress the distribution and a reasonable tar to unpack it. If your tar program supports the z option, it can both uncompress and unpack the file.

GNU tar is known to work. The standard tar provided with some operating systems is not able to unpack the long file names in the MySQL distribution. You should download and install GNU tar, or if available, use a preinstalled version of GNU tar. Usually this is available as gnutar, gtar, or as tar within a GNU or Free Software directory, such as /usr/sfw/bin or /usr/local/bin. GNU tar is available from http://www.gnu.org/software/tar/.

If your tar does not have z option support, use gunzip to unpack the distribution and tar to unpack it. Replace the preceding tar command with the following alternative command to uncompress and extract the distribution:

shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -

Next, create a symbolic link to the installation directory created by tar:

shell> ln -s full-path-to-mysql-VERSION-OS mysql

 

The ln command makes a symbolic link to the installation directory. This enables you to refer more easily to it as /usr/local/mysql. To avoid having to type the path name of client programs always when you are working with MySQL, you can add the /usr/local/mysql/bin directory to your PATH variable:

shell> export PATH=$PATH:/usr/local/mysql/bin

 

Perform Postinstallation Setup

The remainder of the installation process involves setting distribution ownership and access permissions, initializing the data directory, starting the MySQL server, and setting up the configuration file. For instructions, see Section 2.10, “Postinstallation Setup and Testing”.

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Rohit M on March 16, 2011
This step will be helpful in Installation of MySQL.One needs to follow additional step of changing the file ownership.

Even after executing following command as mentioned in the document:
chown -R mysql .
chgrp -R mysql .
There are four symbolic link files whose ownership is not changed(/usr/mysql/lib).
lrwxrwxrwx 1 7155 staff 24 Mar 9 06:28 libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
lrwxrwxrwx 1 7155 staff 24 Mar 9 06:28 libmysqlclient.so -> libmysqlclient.so.16.0.0
lrwxrwxrwx 1 7155 staff 26 Mar 9 06:28 libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
lrwxrwxrwx 1 7155 staff 26 Mar 9 06:28 libmysqlclient_r.so -> libmysqlclient_r.so.16.0.0

In order to change ownership of these files one needs to use following command.
chown -h mysql:mysql libmysqlclient.so.16 libmysqlclient.so libmysqlclient_r.so.16 libmysqlclient_r.so
 
  Posted by Andrew Carr on March 21, 2011
The previous comment depends on which operating system you are using. I am running slackware w/ kernel 2.6.33.4-smp and I did not have to specifically rename the symbolic links.
 
  Posted by on December 13, 2011
In CentOS 6 (the only version I have studied deeply so far) the following commands change the owner of all files (even hidden ones and symbolic links):

chown -R mysql .
chgrp -R mysql .

I did it in one step, though:
chown -R mysql:mysql .

So, despite the fact that Rohit Mahambre's comments might be helpful when using other distros, in CentOS 6 there is no need to use more commands.

This is the output of ls -la for my lib subdirectory:
[george@CentOS-6-host lib]$ ls -la
total 224776
drwxr-xr-x. 3 mysql mysql 4096 Dec 12 18:56 .
drwxr-xr-x. 13 mysql mysql 4096 Dec 12 18:59 ..
-rw-r--r--. 1 mysql mysql 14768868 Nov 23 10:32 libmysqlclient.a
lrwxrwxrwx. 1 mysql mysql 16 Dec 12 18:56 libmysqlclient_r.a -> libmysqlclient.a
lrwxrwxrwx. 1 mysql mysql 17 Dec 12 18:56 libmysqlclient_r.so -> libmysqlclient.so
lrwxrwxrwx. 1 mysql mysql 17 Dec 12 18:56 libmysqlclient_r.so.18 -> libmysqlclient.so
lrwxrwxrwx. 1 mysql mysql 17 Dec 12 18:56 libmysqlclient_r.so.18.0.0 -> libmysqlclient.so
lrwxrwxrwx. 1 mysql mysql 20 Dec 12 18:56 libmysqlclient.so -> libmysqlclient.so.18
lrwxrwxrwx. 1 mysql mysql 24 Dec 12 18:56 libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
-rwxr-xr-x. 1 mysql mysql 6844990 Nov 23 10:32 libmysqlclient.so.18.0.0
-rw-r--r--. 1 mysql mysql 103358370 Nov 23 10:36 libmysqld.a
-rw-r--r--. 1 mysql mysql 104165746 Nov 23 10:26 libmysqld-debug.a
-rw-r--r--. 1 mysql mysql 9584 Nov 23 10:28 libmysqlservices.a
-rw-r--r--. 1 mysql mysql 997127 Nov 23 10:21 libtcmalloc_minimal.so
drwxr-xr-x. 3 mysql mysql 4096 Dec 12 18:55 plugin
  Posted by Steven Garner on February 17, 2013
On Ubuntu 12-04 LTS, you will need to perform:

cp support-files/my-default.cnf /etc/mysql/my.cnf

instead of the step:

cp support-files/my-medium.cnf /etc/my.cnf
  Posted by Jose Luis Bernal Zambrano on June 15, 2015
Alternatively to:

chown -R mysql .
chgrp -R mysql .

With this method isn't needed to do inside specific directory
chown -R mysql:mysql /usr/local/mysql/
Sign Up Login You must be logged in to post a comment.

转载于:https://my.oschina.net/rootliu/blog/3007421

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值