mysql linux免编译版 安装教程

 #在linux/unix上使用通用二进制文件安装mysql
#英文部分转自mysql官网  注释部分为本人翻译

2.2 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. For other platform-specific package formats, see the other platform-specific sections. For example, for Windows distributions, see Section 2.3, “Installing MySQL on Microsoft Windows”.

To obtain MySQL, see Section 2.1.2, “How to Get MySQL”.
#安装mysql之前 需要安装libaio库 以下是libaio在不同包管理器下的安装方式 yum 和apt

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.34), 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-get, 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 infoshell> yum install libaio # install library

Or, on APT-based systems:

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

If you run into problems and need to file a bug report, please use the instructions in Section 1.6, “How to Report Bugs or Problems”.

On Unix, 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
#这是mysql的目录结构

DirectoryContents of Directory
bin, scriptsmysqld server, client and utility programs
dataLog files, databases
docsMySQL manual in Info format
manUnix manual pages
includeInclude (header) files
libLibraries
shareMiscellaneous support files, including error messages, sampleconfiguration files, SQL for database installation
sql-benchBenchmarks

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  #创建mysql组
shell> useradd -r -g mysql -s /bin/false mysql #创建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> chown -R mysql #将mysql目录拥有者更改为mysql用户
shell> chgrp -R mysql #将mysql目录组拥有者更改为mysql组
shell> scripts/mysql_install_db --user=mysql#安装初始化数据库 包含mysql基础表 如mysql.user
shell> bin/mysqld_safe --user=mysql & 后台启动mysql服务
 
# Next command is optionalshell>
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 (OpenSolaris) 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 one. 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, or they may have different names such as adduser and addgroup.

shell> groupadd mysqlshell> 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.



如果在以上步骤中 自定义了安装目录 请往下继续


创建/etc/my.cnf文件

文件主要内容
[mysqld]
basedir="/home/lxl/dev/mysql-5.6.31" #自定义mysql安装主目录
datadir="/home/lxl/dev/mysql-5.6.31/data" #数据库数据文件目录
character-set-server=utf8#服务器字符集
[client]
default-character-set=utf8#客户端链接字符集
[mysql]
default-character-set=utf8#

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值