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

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
