Home Database Mysql Tutorial mysql源码分发版​详细安装过程_MySQL

mysql源码分发版​详细安装过程_MySQL

Jun 01, 2016 pm 01:43 PM
mysql

bitsCN.com 以下是安装MySQL源码分发版的更详细的描述:
1.    为mysqld增加一个登录用户和组:
2.            shell> groupadd mysql3.            shell> useradd -g mysql mysql这些命令将增加MySQL组和MySQL用户。不同版本的Unix中,useradd 和groupadd的语法可能会稍有不同。还可以称为adduser和addgroup。
你可能会将这些用户和组命名为mysql之外的名称。如果是这样,在下面的步骤中替换为相应的名称。
4.    挑选一个你想解开分发包的目录,进入该目录。
5.    从2.1.3节,"怎样获得MySQL"中列出的站点之一获得一个分发文件。
6.    在当前目录下解包分发版:
7.            shell> gunzip 使用GNU tar,则不再需要gunzip。你可以用下面的命令来解包和提取分发:
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz8.    进入解包分发版的顶级目录:
9.            shell> cd  mysql-VERSION请注意目前必须从顶级目录配置和构建MySQL。你不能在其它目录中构建。
10.配置发布版并且编译:
11.        shell> ./configure --prefix=/usr/local/mysql12.        shell> make当你运行configure时,你可能想要指定一些选项,运行./configure --help得到一个选项列表。2.8.2节,"典型配置选项"讨论一些很有用的选项。
如果configure失败,你将向MySQL邮件目录发送包含你认为能帮你解决该问题的包含"config.log"中所有行的邮件,也要包括configure的最后几行输出。用mysqlbug脚本邮寄错误报告。请参见1.7.1.3节,"如何通报缺陷和问题"。
如果编译失败,参见2.8.4节,"处理MySQL编译问题"寻求帮助。
13.安装分发版:
14.        shell> make install如果你想要设置一个选项文件,使用support-files目录中的一个作为模板。例如:
shell> cp support-files/my-medium.cnf /etc/my.cnf可能你需要用root用户运行这些命令。
如果想要配置为支持InnoDB表,应当编辑/etc/my.cnf文件,去掉innodb_...开始选项行前面的#符,并将选项值改为你想要的。请参见4.3.2节,"使用选项文件"和15.2.3节,"InnoDB配置"。
15.进入安装目录:
16.        shell> cd /usr/local/mysql17.如果还没有安装的MySQL,必须创建MySQL授权表:
18.        shell> bin/mysql_install_db --user=mysql如果用root运行命令,应当使用--user选项。选项的值应与你在第一步为运行服务器所创建的登录账户相同。如果用该用户登录来运行命令,可以省略--user选项。
用mysql_install_db创建MySQL授权表后,需要手动重新启动服务器
19.将程序二进制的所有权改为root,数据目录的所有权改为你运行mysqld的用户。如果位于安装目录(/usr/local/mysql)下,命令应为:
20.        shell> chown -R root  .21.        shell> chown -R mysql var22.        shell> chgrp -R mysql .第一个命令将文件的所有属性改为root用户。第二个命令将数据目录的所有属性改为mysql用户。第三个命令将组属性改为mysql组。
23.如果你喜欢在引导机器时自动启动MySQL,你可以拷贝support-files/mysql.server文件到你系统有启动文件的地方。更多的信息可以在support-files/mysql.server脚本中和2.9.2.2节,"自动启动和停止MySQL"中找到。
24.如果安装了DBI和DBD::mysql Perl模块,可以使用bin/mysql_setpermission脚本增加新账户。关于说明,参见2.13节,"Perl安装注意事项"。
在所有东西被安装以后,你应当使用该命令初始化并且测试你的分发版:
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &如果这个命令提示mysqld daemon ended并马上失败,那么你能在数据目录中的文件"hostname'.err"找到一些信息。
关于mysqld_safe的详细信息参见5.1.3节,"mysqld_safe:MySQL服务器启动脚本"。
注释:MySQL授权表中的账户开始没有密码。启动服务器后,你应当使用2.9节,"安装后的设置和测试"中的说明来设置密码。
2.8.2. 典型配置选项configure脚本给你一个很大的控制权来控制如何配置MySQL源码分发版。一般使用configure命令行的选项来进行。你也可以用某些环境变量作用于configure。请参见附录F:环境变量。要查看configure支持的选择列表,可以运行命令:
shell> ./configure --help如果只编译MySQL客户端库和客户端程序而不是服务器,使用--without-server选项:
shell> ./configure --without-server
如果你没有C++编译器,则不能编译mysql(有一个客户端程序需要C++)。在这种情况下,你可以去掉configure里面测试C++编译器的代码,然后运行带有--without-server选项的./configure。编译步骤步将仍然尝试构造mysql,但是你可以忽略任何关于"mysql.cc"的警告。(如果make停止,试试make -k告诉它即使出错继续剩下的构造步骤)。
·         如果你想要构建嵌入式MySQL库(libmysqld.a),你应当使用--with-embedded-server选项。
如果你不想要位于"/usr/local/var"目录下面的日志(log)文件和数据库,使用类似于下列configure命令的一个:
shell>./configure--prefix=/usr/local/mysql
shell>./configure--prefix=/usr/local –
       localstatedir=/usr/local/mysql/data
第一个命令改变安装前缀以便将所有内容安装到"/usr/local/mysql"下面而非 默认的"/usr/local"。第二个命令保留默认安装前缀,但是覆盖了数据库目录默认目录(通常是"/usr/local/var")并且把它改为/usr/local/mysql/data。编译完MySQL后,可以通过选项文件更改这些选项。请参见4.3.2节,"使用选项文件"。
如果你正在使用Unix并且你想要MySQL的套接字位于 默认位置以外的某个地方(通常在目录"/tmp"或"/var/run",使用象这样的configure的命令:
shell> ./configure/-- with-unix-socket-
path=/usr/local/mysql/tmp/mysql.sock
注意给出的文件名必须是一个绝对路径。你还可以在以后使用MySQL选项文件更改mysql.sock的位置。请参见A.4.5节,"如何保护或更改MySQL套接字文件/tmp/mysql.sock"。
如果你想编译静态链接程序(例如,制作二进制分发版、获得更快的速度或与解决与RedHat分发版的一些问题),像这样运行configure:
·                shell>./configure --with-client-ldflags=-all-static/
·                        --with-mysqld-ldflags=-all-static
如果你正在使用gcc并且没有安装libg++或libstdc++,你可以告诉configure使用gcc作为C++编译器:
shell> CC=gcc  CXX=gcc  ./configure
当你使用gcc作为C++编译器用时,它将不试图链接libg++或libstdc++。即使你安装了这些库,这样也很好,因为过去使用MySQL时,它们的部分版本会出现一些奇怪的问题。
下面列出了一些经常使用的编译器和环境变量设定值。
o        gcc 2.7.2:
o                     CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors"o        egcs 1.0.3a:
o                     CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors /o                     -fno-exceptions -fno-rtti"o        gcc 2.95.2:
o                     CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro /o                     -felide-constructors -fno-exceptions -fno-rtti"o        pgcc 2.90.29 或更新版:
o                     CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc /o                     CXXFLAGS="-O3 -mpentiumpro -mstack-align-double /o                     -felide-constructors -fno- exceptions -fno-rtti"在大多数情况,在configure行使用前面列出的选项并加入下面的选项,可以得到合理的优化的MySQL二进制:
--prefix=/usr/local/mysql --enable-assembler /--with-mysqld-ldflags=-all-static换句话说,对于所有最近的gcc版,整个configure行应为:
CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro /-felide-constructors -fno- exceptions -fno-rtti" ./ configure /--prefix=/usr/local/mysql --enable-assembler /--with-mysqld-ldflags=-all-static我们在MySQL网址http://www.mysql.com/提供的二进制均已经编译过并进行了优化,对于大多数用户应当比较完善。请参见2.1.2.5节,"MySQL AB编译的MySQL二进制版本"。其中有一些配置设定值,可以选用来构建更快的二进制,但是只适用高级用户。请参见7.5.4节,"编译和链接怎样影响MySQL的速度"。
如果构造失败并且产生有关编译器或链接器的错误,不能创建共享库"libmysqlclient.so.#"("#"是一个版本号), 你可以通过为configure指定--disable-shared选项来解决此问题。在这种情况下,configure将不构造一个共享libmysqlclient.so.#库。
默认地,MySQL使用latin1(cp1252)字符集。为了改变 默认设置,使用--with-charset选项:
shell> ./configure -- with-charset=CHARSET
CHARSET可以是big5、cp1251、cp1257、czech、danish、dec8、dos、euc_kr、gb2312、gbk、german1、hebrew、hp8、hungarian、koi8_ru、koi8_ukr、latin1、latin2、sjis、swe7、tis620、ujis、usa7或win1251ukr。请参见5.10.1节,"数据和排序用字符集"。
可以指定默认校对规则。MySQL默认使用latin1_swedish_ci校对规则。要想更改,使用--with-collation选项:
shell> ./configure --with-collation=COLLATION要想更改字符集和校对规则,要同时使用--with-charset和--with-collation选项。 校对规则必须是字符集的合法校对规则。(使用SHOW COLLATION语句来确定每个字符集使用哪个校对规则)。
如果想在服务器和客户端之间变换字符,你应该看一下SET OPTION CHARACTER SET命令。请参见13.5.3节,"SET语法"。
警告:如果你在创建了任何数据库表之后改变字符集,你将必须对每个表运行myisamchk -r -q --set-character-set=charset,否则索引可能不正确地排序。(如果安装了MySQL,创建一些表,然后重新配置MySQL使用一个不同的字符集并且重新安装它,这时就可能发生这种情况。)
通过configure选项--with-extra-charsets=LIST,你可以定义在服务器中再定义哪些字符集。LIST 指下面任何一项:
o        空格间隔的一系列字符集名
o        complex -,以包括不能动态装载的所有字符集
o        all –,以将所有字符集包括进二进制
为了配置MySQL带有调试代码,使用--with-debug选项:
shell> ./configure --with-debug
这导致包含一个安全的内存分配器,能发现一些错误和并提供关于正在发生的事情的输出。请参见E.1节,"调试MySQL服务器"。
·         如果客户端程序使用线程,还必须使用--enable-thread-safe-client配置选项来编译线程安全版的MySQL客户端库。将创建一个libmysqlclient_r库,可以用来连接应用程序线程。请参见25.2.15节,"如何生成线程式客户端"。
·         可以使用--with-big-tables选项构建支持大数据库表的MySQL。
该选项使变量用来将表行数保存到unsigned long long中而不是unsigned long。结果是允许表有大约1.844E+19 ((232)2)行而不是232 (~4.295E+09) 行。在以前,要完成该功能必须手动将-DBIG_TABLES传递给编译器。
属于特定系统的选项可在本章特定系统的小节里找到。请参见2.12节,"具体操作系统相关的注意事项" bitsCN.com

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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks 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)

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Do mysql need to pay Do mysql need to pay Apr 08, 2025 pm 05:36 PM

MySQL has a free community version and a paid enterprise version. The community version can be used and modified for free, but the support is limited and is suitable for applications with low stability requirements and strong technical capabilities. The Enterprise Edition provides comprehensive commercial support for applications that require a stable, reliable, high-performance database and willing to pay for support. Factors considered when choosing a version include application criticality, budgeting, and technical skills. There is no perfect option, only the most suitable option, and you need to choose carefully according to the specific situation.

RDS MySQL integration with Redshift zero ETL RDS MySQL integration with Redshift zero ETL Apr 08, 2025 pm 07:06 PM

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.

Query optimization in MySQL is essential for improving database performance, especially when dealing with large data sets Query optimization in MySQL is essential for improving database performance, especially when dealing with large data sets Apr 08, 2025 pm 07:12 PM

1. Use the correct index to speed up data retrieval by reducing the amount of data scanned select*frommployeeswherelast_name='smith'; if you look up a column of a table multiple times, create an index for that column. If you or your app needs data from multiple columns according to the criteria, create a composite index 2. Avoid select * only those required columns, if you select all unwanted columns, this will only consume more server memory and cause the server to slow down at high load or frequency times For example, your table contains columns such as created_at and updated_at and timestamps, and then avoid selecting * because they do not require inefficient query se

How to fill in mysql username and password How to fill in mysql username and password Apr 08, 2025 pm 07:09 PM

To fill in the MySQL username and password: 1. Determine the username and password; 2. Connect to the database; 3. Use the username and password to execute queries and commands.

How to optimize MySQL performance for high-load applications? How to optimize MySQL performance for high-load applications? Apr 08, 2025 pm 06:03 PM

MySQL database performance optimization guide In resource-intensive applications, MySQL database plays a crucial role and is responsible for managing massive transactions. However, as the scale of application expands, database performance bottlenecks often become a constraint. This article will explore a series of effective MySQL performance optimization strategies to ensure that your application remains efficient and responsive under high loads. We will combine actual cases to explain in-depth key technologies such as indexing, query optimization, database design and caching. 1. Database architecture design and optimized database architecture is the cornerstone of MySQL performance optimization. Here are some core principles: Selecting the right data type and selecting the smallest data type that meets the needs can not only save storage space, but also improve data processing speed.

Understand ACID properties: The pillars of a reliable database Understand ACID properties: The pillars of a reliable database Apr 08, 2025 pm 06:33 PM

Detailed explanation of database ACID attributes ACID attributes are a set of rules to ensure the reliability and consistency of database transactions. They define how database systems handle transactions, and ensure data integrity and accuracy even in case of system crashes, power interruptions, or multiple users concurrent access. ACID Attribute Overview Atomicity: A transaction is regarded as an indivisible unit. Any part fails, the entire transaction is rolled back, and the database does not retain any changes. For example, if a bank transfer is deducted from one account but not increased to another, the entire operation is revoked. begintransaction; updateaccountssetbalance=balance-100wh

How to copy and paste mysql How to copy and paste mysql Apr 08, 2025 pm 07:18 PM

Copy and paste in MySQL includes the following steps: select the data, copy with Ctrl C (Windows) or Cmd C (Mac); right-click at the target location, select Paste or use Ctrl V (Windows) or Cmd V (Mac); the copied data is inserted into the target location, or replace existing data (depending on whether the data already exists at the target location).

See all articles