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

AI Hentai Generator
Generate AI Hentai for free.

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

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.
