Home Database Mysql Tutorial Linux手动安装Mysql

Linux手动安装Mysql

Jun 07, 2016 pm 03:01 PM
linux mysql Install

以下是摘自mysql官方文档中关于手动安装MySQL 二进制分发版的说明: 一:安装 必须执行以便安装并使用MySQL 二进制分发版的基本命令是: shell groupadd mysql shell useradd -g mysql mysql shell cd /usr/local shell gunzip /path/to/mysql-VERSION-OS .ta

以下是摘自mysql官方文档中关于手动安装MySQL 二进制分发版的说明:

一:安装 

必须执行以便安装并使用MySQL 二进制分发版的基本命令是:

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> cd /usr/local

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

shell> cd mysql

shell> scripts/mysql_install_db --user=mysql

shell> chown -R root  .

shell> chown -R mysql data

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &
 

注释: 该过程未设置MySQL账户的密码。完成下面的过程后,继续执行想2.9节,“安装后的设置和测试” 。

下面为安装二进制分发版的更详细的描述:

1.    为mysqld 增加一个登录用户和组:

2.    shell> groupadd mysql 

3.    shell> useradd -g mysql mysql 

      这些命令将增加MySQL组和MySQL用户。不同版本的Unix中,useradd 和groupadd 的语法可能会稍有不同。还可以称为adduser 和addgroup 。你可能会将这些用户和组命名为mysql之外的名称。如果是这样,在下面的步骤中替换为相应的名称。

4.    挑选一个你想解开分发包的目录,进入该目录。在下面的例子中,我们将分发解包在“/usr/local”下(因此,下列说明假设你有权限在“/usr/local”中创建文件和目录,如果该目录被保护,你需要以root实施安装)。

5.    shell> cd /usr/local

6.    从2.1.3节,“怎样获得MySQL”中列出的站点之一获得一个分发文件。对于一个给定的版本,所有平台的二进制分发版均从相同的MySQL源码分发版构建。

7.    解包分发版,将创建安装目录。然后生成到该目录的一个符号链接:

8.    shell> gunzip  

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

      tar 命令创建mysql-VERSION -OS 目录。ln命令生成到该目录的一个符号链接。这让你更容易地把安装目录指定为/usr/local/mysql。使用GNU tar ,则不再需要gunzip。可以用下面的命令替换第一行来解包和提取分发版:

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

10.   进入安装目录:

11.   shell> cd mysql

      你会在mysql目录下发现几个文件和子目录,对安装目的最重要的是“bin”和“scripts”子目录。bin这个目录包含客户端程序和服务器,你应该把这个目录的完整路径加到PATH环境变量,以便shell能正确的找到MySQL程序。请参见附录F: 环境变量 。scripts这个目录包含mysql_install_db脚本,用来初始化mysql数据库的 授权表,其中贮存了服务器访问允许。

12.   如果还没有安装MySQL,必须创建MySQL授权表

13.   shell> scripts/mysql_install_db --user=mysql 

      如果你用root运行命令,应当使用--user选项。选项的值应与你在第一步为运行服务器所创建的登录账户相同。如果你用该用户登录来运行命令,可以省略--user选项。创建或升级授权表后,需要手动重新启动服务器。

14.   将程序二进制的所有权改为root,数据目录的所有权改为运行mysqld 的用户。如果位于安装目录(/usr/local/mysql)下,命令应为:

15.   shell> chown -R root  . 

16.   shell> chown -R mysql data 

17.   shell> chgrp -R mysql . 

      第一个命令将文件的所有属性改为root用户。第二个命令将数据目录的所有属性改为mysql用户。第三个命令将组属性改为mysql组。

18.   如果你喜欢在引导机器时自动启动MySQL,可以拷贝support-files/mysql.server文件到系统有启动文件的地方。更多的信息可以在support-files/mysql.server脚本中和2.9.2.2节,“自动启动和停止MySQL” 中找到。

19.   如果安装了DBI和DBD::mysql Perl模块,可以使用bin/mysql_setpermission 脚本增加新账户。关于说明,参见 2.13节,“Perl安装注意事项” 。


20.   如果你想使用mysqlaccess 而在某个非标准的地点有MySQL分发版,你必须改变地点,在那儿mysqlaccess 期望找到mysql 客户端。编辑“bin/mysqlaccess”脚本,大约在第18行,寻找类似下面的行:

21.   MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable

      改变路径以反映出mysql 实际存储在你系统上的地点。如果不这样做,当运行mysqlaccess 时,你将遇到一个broken pipe的错误。在所有东西被解包并且安装以后,你应该初始化并且测试你的分发版。可以用下列命令启动MySQL服务器:

      shell> bin/mysqld_safe --user=mysql & 

      关于mysqld_safe 的详细信息参见5.1.3节,“mysqld_safe:MySQL服务器启动脚本” 。

      注释: MySQL授权表中的账户开始没有密码。启动服务器后,应当使用2.9节,“安装后的设置和测试” 中的说明来设置密码。

二:设置开机自动运行 

      对于手动安装的二进制分发版本,我们可以在在MySQL安装目录下的support-files目录中找到一个名为mysql.server脚本。我们需要将这个脚本复制到/etc/init.d目录下,同时更名为mysql,并设定该文件可执行.


shell> cp mysql.server /etc/init.d/mysql


shell> chmod +x /etc/init.d/mysql


       接下来的工作可能会因为Linux版本的不同而有所差异。对于有些系统,我们可以使用chkconfig --add mysql 来完成启动程序的注册。而对于Ubuntu系统来说,我们应该使用ubuntu自带的update-rc.d解决(chkconfig为linux自带 ,新近发行的Ubuntu版本并不包含这个命令)


shell>sudo update-rc.d mysql defaults


经过上述设置,mysql就可以在ubuntu中开机自动运行了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Ouyi okx installation package is directly included Ouyi okx installation package is directly included Feb 21, 2025 pm 08:00 PM

Ouyi OKX, the world's leading digital asset exchange, has now launched an official installation package to provide a safe and convenient trading experience. The OKX installation package of Ouyi does not need to be accessed through a browser. It can directly install independent applications on the device, creating a stable and efficient trading platform for users. The installation process is simple and easy to understand. Users only need to download the latest version of the installation package and follow the prompts to complete the installation step by step.

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Get the gate.io installation package for free Get the gate.io installation package for free Feb 21, 2025 pm 08:21 PM

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

Ouyi Exchange Download Official Portal Ouyi Exchange Download Official Portal Feb 21, 2025 pm 07:51 PM

Ouyi, also known as OKX, is a world-leading cryptocurrency trading platform. The article provides a download portal for Ouyi's official installation package, which facilitates users to install Ouyi client on different devices. This installation package supports Windows, Mac, Android and iOS systems. Users can choose the corresponding version to download according to their device type. After the installation is completed, users can register or log in to the Ouyi account, start trading cryptocurrencies and enjoy other services provided by the platform.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? Apr 01, 2025 pm 03:03 PM

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

gate.io official website registration installation package link gate.io official website registration installation package link Feb 21, 2025 pm 08:15 PM

Gate.io is a highly acclaimed cryptocurrency trading platform known for its extensive token selection, low transaction fees and a user-friendly interface. With its advanced security features and excellent customer service, Gate.io provides traders with a reliable and convenient cryptocurrency trading environment. If you want to join Gate.io, please click the link provided to download the official registration installation package to start your cryptocurrency trading journey.

See all articles