mysql linux免编译版 安装教程
2016-08-27 15:05
387 查看
#在linux/unix上使用通用二进制文件安装mysql
#英文部分转自mysql官网 注释部分为本人翻译
tar files (files with a
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
Warning
If you have previously installed MySQL using your operating system native package management system, such as
of your data files, have also been removed. You should also check for configuration files such as
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
on Yum-based systems:
shell>
Or, on APT-based systems:
shell>
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
Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package
#这是mysql的目录结构
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>
shell>
Note
This procedure assumes that you have
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
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.
mysqld, you may need to create one. The following commands add the
useradd and groupadd may differ slightly on different versions of Unix, or they may have different names such as
adduser and addgroup.
shell>
Note
Because the user is required only for ownership
926a
purposes, not login purposes, the
useradd command uses the
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#
#英文部分转自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 compressedtar files (files with a
.tar.gzextension) 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-.tar.gz[/code], whereVERSION-[code]OS
VERSION[/code] is a number (for example,
5.6.34), and
OSindicates the type of operating system for which the distribution is intended (for example,
pc-linux-i686or
winx64).
Warning
If you have previously installed MySQL using your operating system native package management system, such as
yumor
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.cnfor the
/etc/mysqldirectory 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
libaiolibrary. 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的目录结构
Directory | Contents of Directory |
---|---|
bin, scripts | mysqld server, client and utility programs |
data | Log files, databases |
docs | MySQL manual in Info format |
man | Unix manual pages |
include | Include (header) files |
lib | Libraries |
share | Miscellaneous support files, including error messages, sampleconfiguration files, SQL for database installation |
sql-bench | Benchmarks |
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 zxvfshell>/path/to/mysql-VERSION-OS.tar.gz #解压免编译安装包
ln -sshell>full-path-to-mysql-VERSION-OSmysql# 创建快捷方式 可选操作
cd mysql #跳转到解压完毕的目录shell>
chown -R mysql #将mysql目录拥有者更改为mysql用户shell>
chgrp -R mysql#将mysql目录组拥有者更改为mysql组
shell>
scripts/mysql_install_db --user=mysql#安装初始化数据库 包含mysql基础表 如mysql.usershell>
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.cnfin 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 runningmysqld, you may need to create one. The following commands add the
mysqlgroup and the
mysqluser. 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
926a
purposes, not login purposes, the
useradd command uses the
-rand
-s /bin/falseoptions 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#
相关文章推荐
- MySQL中的integer 数据类型
- Linux socket 初步
- MySQL存储过程
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv