Installing MySQL on Unix/Linux Using Generic Binaries
2016-12-18 17:36
381 查看
wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
1、groupadd mysql ## 添加一个mysql组2、useradd -r -g mysql mysql ## 添加一个用户3、解压缩下载的包,tar -xzvf /data/software/mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz4、然后 mv 解压后的包 mysql ##相当于重命名5、 chown -R mysql:mysql ./ ##进入mysql包中, 给这个包授权 给mysql6、bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data ##进入mysql文件名 basedir 为mysql 的路径, datadir 为mysql的 data 包,里面存放着mysql自己的包, 如user 重要:此处需要注意记录生成的临时密码,如上文:YLi>7ecpe;YP7、bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data 8、进入mysql support-files9、cp my-default.cnf /etc/my.cnf10、cp mysql.server /etc/init.d/mysql11、vim /etc/init.d/mysql ##修改basedir= 自己的路径 修改datadir= 自己的路径12、bin/mysqld_safe --user=mysql & ## 启动mysql13、bin/mysql --user=root –p 14、 输入临时密码15、 set password=password('A123456');16、grant all privileges on *.* to root@'%' identified by 'A123456';17、flush privileges;18、use mysql;19、select host,user from user;
=================
Oracle provides a set of binary distributions of MySQL. These include generic binary distributions in the form of compressed tar files (files with a
If you have previously installed MySQL using your operating system native package management system, such as
Warning
MySQL has a dependency on the
Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package
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:
This procedure assumes that you have
Before MySQL 5.7.4, 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”.The
As of MySQL 5.7.18,
Because the user is required only for ownership purposes, not login purposes, the useradd command uses the
The
转自:http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html#binary-installation-layout
1、groupadd mysql ## 添加一个mysql组2、useradd -r -g mysql mysql ## 添加一个用户3、解压缩下载的包,tar -xzvf /data/software/mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz4、然后 mv 解压后的包 mysql ##相当于重命名5、 chown -R mysql:mysql ./ ##进入mysql包中, 给这个包授权 给mysql6、bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data ##进入mysql文件名 basedir 为mysql 的路径, datadir 为mysql的 data 包,里面存放着mysql自己的包, 如user 重要:此处需要注意记录生成的临时密码,如上文:YLi>7ecpe;YP7、bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data 8、进入mysql support-files9、cp my-default.cnf /etc/my.cnf10、cp mysql.server /etc/init.d/mysql11、vim /etc/init.d/mysql ##修改basedir= 自己的路径 修改datadir= 自己的路径12、bin/mysqld_safe --user=mysql & ## 启动mysql13、bin/mysql --user=root –p 14、 输入临时密码15、 set password=password('A123456');16、grant all privileges on *.* to root@'%' identified by 'A123456';17、flush privileges;18、use mysql;19、select host,user from user;
=================
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.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 compressed tar file binary distributions have names of the form
mysql-VERSION
-OS.tar.gz, where
VERSION
is a number (for example, 5.7.18), 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 info shell> yum install libaio # install libraryOr, on APT-based systems:
shell> apt-cache search libaio # search for info shell> apt-get install libaio1 # install libraryIf you run into problems and need to file a bug report, please use the instructions in Section 1.7, “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
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, sample configuration files, SQL for database installation |
To install and use a MySQL binary distribution, the command sequence looks like this:
shell> groupadd mysqlshell> useradd -r -g mysql -s /bin/false mysqlshell> cd /usr/localshell> tar zxvf /path/to/mysql-VERSION-OS.tar.gzshell> ln -s full-path-to-mysql-VERSION-OS mysqlshell> cd mysqlshell> mkdir mysql-filesshell> chmod 750 mysql-filesshell> chown -R mysql .shell> chgrp -R mysql .shell> scripts/mysql_install_db --user=mysql# MySQL 5.7.0 to 5.7.4 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-filesshell> bin/mysqld_safe --user=mysql Next command is optional shell> cp support-files/mysql.server /etc/init.d/mysql.serverNote
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
Before MySQL 5.7.4, 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”.The
mysql-filesdirectory provides a convenient location to use as the value of the
secure_file_privsystem variable that limits import/export operations to a specific directory. See Section 6.1.5, “Server System Variables”.Before MySQL 5.7.5, 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 6.1.2, “Server Configuration Defaults”.Note
As of MySQL 5.7.18,
my-default.cnfis no longer included in or installed by distribution packages.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 themysqlgroup 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 asadduser and addgroup.
shell> groupadd mysqlshell> useradd -r -g mysql -s /bin/false mysqlNote
Because the user is required only for ownership 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 useradddoes 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/localObtain 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
zoption support:
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gzThe tar command creates a directory named
mysql-VERSION
-OS.To install MySQL from a compressed tar file binary distribution, your system must have GNU
gunzipto uncompress the distribution and a reasonable tarto unpack it. If your tar program supports the
zoption, 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/binor
/usr/local/bin. GNU tar is available from http://www.gnu.org/software/tar/.If your tar does not have
zoption 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
lncommand 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/bindirectory to your
PATHvariable:
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”.转自:http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html#binary-installation-layout
相关文章推荐
- Installing MySQL on Unix/Linux Using Generic Binaries
- Installing MySQL on Unix/Linux Using Generic Binaries
- MySQL学习笔记2-System administration(Installing MySQL on Linux Using RPM Packages)
- 官网 Mysql Installing MySQL on Linux Using RPM Packages from Oracle
- Setup MySQL in user home without superuser using generic linux distribution
- [转]Howto: Connect MySQL server using C program API under Linux or UNIX
- MYSQL 5.7 Linux脚本出现[Warning] Using a password on the command line interface can be insecure.
- Mysql 安装(Using Generic Binaries)
- Installing mysql on windows 7 and using ruby on it
- Installing and using Net-SNMP On Linux
- Installing MySQL on Microsoft Windows Using a noinstall ZIP Archive
- Installing MySQL on Microsoft Windows Using a noinstall Zip Archive,在Windows上使用非安装压缩包安装MySQL
- Installing and using Net-SNMP On Linux
- Howto: Connect MySQL server using C program API under Linux or UNIX
- Howto: Connect MySQL server using C program API under Linux or UNIX
- Mysql 安装(Using Generic Binaries)
- Howto: Connect MySQL server using C program API under Linux or UNIX
- Mysql 安装(Using Generic Binaries)
- Installing Bochs/Unix_v6 on your 32-bit Linux machine
- How To Download a RPM Package Using yum Command Without Installing On Linux