MySQL 5.5 三大安装方式:【二进制、源代码编译 和 RPM 包】 安
㈠ 源代码编译 ① 安装 cmake # wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz # tar -zxv -f cmake-2.8.5.tar.gz -C /usr/local/src # cd /usr/local/src/cmake-2.8.5 # ./bootstrap # make # make install ② 新建 MySQL 用户 # groupadd dba
㈠ 源代码编译① 安装 cmake
# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz # tar -zxv -f cmake-2.8.5.tar.gz -C /usr/local/src # cd /usr/local/src/cmake-2.8.5 # ./bootstrap # make # make install
② 新建 MySQL 用户
# groupadd dba # useradd -g dba mysql # cp mysql-5.5.16.tar.gz /home/mysql/ # chown -R mysql:dba /home/mysql/mysql-5.5.16.tar.gz
③ CMake编译MySQL 5.5
# su - mysql $ tar -zxv -f mysql-5.5.16.tar.gz $ cd mysql-5.5.16 $ CFLAGS="-O3" CXX=gcc $ CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" $ cmake . -LH|more //CMake下查看MySQL的编译配置 $ cmake . -DCMAKE_INSTALL_PREFIX=/home/mysql/mysql -DEXTRA_CHARSETS=all $ make -j 8 //8核并行编译 $ make install
④ 建立配置文件
$ cd /home/mysql/mysql $ su - root # cp /home/mysql/mysql-5.5.16/support-files/my-medium.cnf /etc/my.cnf /*这步骤可以省略、默认会存在一个*/ # chown -R mysql:dba /etc/my.cnf
⑤ 修改配置文件、配置数据文件、日志文件的路径
# su - mysql $ cd mysql $ mkdir run log tmp $ vim /etc/my.cnf **新增内容如下-- basedir = /home/mysql/mysql datadir = /home/mysql/mysql/data socket = /home/mysql/mysql/run/mysql.sock /*Server和client的socket配置都要相同*/ log-error = /home/mysql/mysql/log/alert.log log_slow_queries = /home/mysql/mysql/log/slow.log
注意、5.6版本、开启慢查询日志的方式有些不同、
slow_query_log_file = /home/mysql/mysql/log/slow.log slow_query_log = 1
⑥ 初始化 MySQL 配置表
$ ./scripts/mysql_install_db --basedir=/home/mysql/mysql --datadir=/home/mysql/mysql/data --user=mysql --force
⑦ 启动 mysql
./bin/mysqld_safe &
好处:平台无关、安装的 MySQL 目录独立(方便清楚),据说有更好的性能和平台耦合
缺点: 编译安装较慢
㈡ 二进制分发版安装
官网下二进制分发版的格式是:mysql--
① 创建用户和组
# groupadd dba # useradd -g dba mysql
② 解压到指定目录
# tar -zxv -f mysql-5.5.30-linux2.6-i686.tar.gz -C /usr/local/ # mv /usr/local/mysql-5.5.30-linux2.6-i686 /usr/local/mysql # cd /usr/local/mysql
③ 更改权限
# chown -R mysql . # chgrp -R dba .
④ 初始化 MySQL 配置表
# scripts/mysql_install_db --user=mysql
⑤ 更改数据目录权限
# chown -R root . # chown -R mysql data
⑥ 复制配置文件
# cp support-files/my-medium.cnf /etc/my.cnf
⑦ 建立软链接
# ln -s /usr/local/mysql/bin/mysqld_safe /usr/local/bin # ln -s /usr/local/mysql/bin/mysqladmin /usr/local/bin # ln -s /usr/local/mysql/bin/mysql /usr/local/bin
⑧ 启动MySQL服务
# bin/mysqld_safe --user=mysql &
好处:
MySQL 使用的 glibc 进行开发、glibc 库是一个底层 API、所以只要是 Linux,都会有glibc库、移植性很方便
进制分发版和源码分发版,前者已经编译并经过优化了,后者没有
㈢ RPM 方式
RPM 包方式安装极为简单、这里就不赘述
谈谈其他对象
比如:MySQL 各个 RPM 包是什么意思?
MySQL-VERSION.i386.rpm MySQL服务器。除非你只是想要与运行在其他机器上MySQL服务器连接,否则你将需要它
MySQL-client-VERSION.i386.rpm 标准MySQL客户程序。你可能总是需要安装这个包
MySQL-bench-VERSION.i386.rpm 测试和基准程序。需要Perl和msql-mysql-modules RPM
MySQL-devel-VERSION.i386.rpm 所需的库和包含文件。如果你想要编译其他MySQL客户程序, 例如Perl模块
MySQL-VERSION.src.rpm 包含上述所有包的源代码。它也能被用来尝试为其他硬件平台构造RPM(例如,Alpha或SPARC)
MySQL-Max-VERSION.rpm 包含了客户端和服务器端的程序
MySQL-embedded-VERSION.i386.rpm 和为嵌入式 linux 设计的数据库系统
在大多数情况下,只需要安装MySQL-server 和 MySQL-client,其他的包根据需要来安装
再比如:MySQL RPM 安装后相关目录在哪里?
/usr/bin :客户端程序和脚本、比如 mysqladmin mysqldump等命令
/usr/sbin:mysqld
/var/lib/mysql:数据库的目录
/usr/share/mysql:mysql.server命令及配置文件
/etc/rc.d/init.d/:启动脚本文件mysql的目录
最后、、、、、、
论哪个更好,恐怕没有哪个更好,只能说哪个更适合
青菜萝卜、各有所爱、大家自行权衡

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings

The methods for viewing SQL database errors are: 1. View error messages directly; 2. Use SHOW ERRORS and SHOW WARNINGS commands; 3. Access the error log; 4. Use error codes to find the cause of the error; 5. Check the database connection and query syntax; 6. Use debugging tools.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.
