Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MySQL on unix/linux using binaries

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Let me tell you a little bit about how to use binaries to install MySQL on unix/linux. Have you known about similar topics before? If you are interested, let's take a look at this article. I believe it is more or less helpful to read the operation method of installing MySQL on unix/linux using binaries.

MySQL's tar compressed binary distribution is named mysql-VERSION-OS.tar.gz, the version number is a string of numbers (for example, 5.7.21), and for the distribution you plan to use, os represents the type of operating system (such as pc-linux-i686 or winx64).

Warning

If you have previously installed MySQL with a native package management system, such as yum or apt-get, you may encounter problems when installing using native binaries. Please make sure that your previously installed MySQL has been completely deleted (using your package management system), as well as any other files, such as your old version of the data file, should also be deleted. You should also check the configuration files, such as / etc/my.cnf or / etc/mysql directories, and delete them.

For information about replacing a third-party installation package with an official MySQL installation package, refer to the Apt or Yum guide.

Important matters

MySQL relies on the libaio library. If the library is not installed locally, the initialization of the data directory and the subsequent steps of starting the CVM will fail. If necessary, install it using the appropriate package manager. For example, on a yum-based installation:

Shell > yumsearch libaio # search for info

Shell > yuminstall libaio # install library

Or, on an APT-based installation:

Shell > apt-cachesearch libaio # search for info

Shell > apt-getinstall libaio1 # install library

For MySQL 5.7.19 and later: support for non-uniform memory access (NUMA) has been added to the generic Linux build, which currently relies on the libnuma library; if the library is not installed on your system, use your system's package manager to search for and install it (see the final project for some sample commands).

If you encounter a problem and need to submit an error file, use the instructions in Section 1.7, "how to report an error or problem".

When installing the tar-compressed binary distribution on Unix, unzip it at the installation location of your choice (usually / usr/local/mysql). This creates the directory shown in the table below.

Table 2.3 MySQL installation layout for generic Unix/Linux binaries

Catalogue

Contents of the directory

Bin

Mysqld services, clients and utilities

Data

Log files, data

Docs

MySQL manual in information format

Man

Unix man page

Include

Include (header) file

Lib

Library

Share

Various support files, including error messages, sample configuration files, SQL for database installation

The debug version of the mysqld binaries can be used with mysqld-debug. To compile your own debug version of MySQL from the source code distribution, use the appropriate configuration options to start debugging support. See Section 2.9, "installing MySQL from source code".

To install and use the MySQL binary distribution, the command sequence is as follows:

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 > mkdir mysql-files

Shell > chmod 750mysql-files

Shell > chown-R mysql.

Shell > chgrp-R mysql.

Shell > bin/mysql_install_db-- user=mysql # MySQL 5.7.5

Shell > bin/mysqld-- initialize-- user=mysql # MySQL 5.7.6 and up

Shell > bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up

Shell > chown-R root.

Shell > chown-R mysql data mysql-files

Shell > bin/mysqld_safe-- user=mysql &

# Next command is optional the next command is optional

Shell > cp support-files/mysql.server / etc/init.d/mysql.server

Matters needing attention

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

Matters needing attention

Prior to MySQL 5.7.4, this process did not assign a password to the MySQL account. To do this, use the instructions in Section 2.10.4, "securing the initial MySQL account."

The mysql-files directory provides a convenient location for secure_file_priv system variable values to restrict import / export operations to specific directories. See section 5.1.5, "CVM system variables".

Prior to MySQL 5.7.5, mysql_install_db created a default options file called my.cnf in the basic installation directory. This file is created by a template named my-default.cnf in the distribution. For more information, see Section 5.1.2, "default values for CVM configuration".

Matters needing attention

In the case of MySQL 5.7.18, my-default.cnf is no longer included or installed in the distribution.

The installation of the binary distribution was described earlier, and the more detailed version is as follows.

Create a new mysql user and group

If your system does not already have a user and group to run mysqld, you may need to create one. The following command adds the mysql group and mysql users. You may want to call other users and groups instead of mysql. If so, replace it with the appropriate name in the instructions below. The syntax of useradd and groupadd may be slightly different on different versions of Unix, or they may have different names, such as adduser and addgroup.

Shell > groupadd mysql

Shell > useradd-r-g mysql-s / bin/false mysql

Matters needing attention

Because users only need the ownership function, not the login function, the useradd command uses the-r and-s / bin/false options to create a user who does not have login privileges to your CVM host. If your useradd does not support these options, please ignore them.

Get and unpack the distribution

Select the directory where you want to unpack the distribution, and change the location to this directory. Here is an example of unpacking the distribution under / usr/local. This directive assumes that you have permission to create files and directories in / usr/local. If the directory is protected, you must perform the installation as the root user.

Shell > cd / usr/local

In Section 2.1.2, "how to get MySQL", use this directive to get a distribution file. For a given distribution, the binary distributions of all platforms are built from the same MySQL source distribution.

Unpack the distribution in the new installation directory. If supported by the z option, tar can unpack and unpack distributions:

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

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

To install MySQL from a compressed binary distribution of tar files, your system must have GNU gunzip to extract the distribution and a reasonable tar program to unpack it. If your tar program supports the z option, it can either unpack or unpack files.

The role of GNU tar is well known. In MySQL distributions, some operating systems provide standard tar that cannot be unpackaged with long filenames. You should download and install GNUtar, or use a pre-installed version of GNUtar, if any. Generally available in GNU or free software directories is gnutar,gtar or tar, 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 support the z option, use gunzip to unpack the distribution and tar to unpack it. Replace the previous tar command with the following alternative command to extract and extract the distribution:

Shell > gunzip

< /path/to/mysql-VERSION-OS.tar.gz | tar xvf - 接下来,对tar创建的安装目录新建一个符号链接: shell>

Ln-s full-path-to-mysql-VERSION-OS mysql

The ln command creates a symbolic link to the installation directory. This makes it easier for you to access it as / usr/local/mysql. When you are working with MySQL, you can always avoid printing the pathname of the client program. You can add the / usr/local/mysql/bin directory to your PATH variable:

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

Perform post-installation settings

The rest of the installer includes setting the ownership and access rights of the distribution, initializing the data directory, starting the MySQL cloud server, and setting configuration files. For instructions, see Section 2.10, "setup and testing after installation".

What do you think of how to use binaries to install MySQL on unix/linux? what do you think of this article? If you want to know more about it, you can continue to follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report