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的目录
最后、、、、、、
论哪个更好,恐怕没有哪个更好,只能说哪个更适合
青菜萝卜、各有所爱、大家自行权衡

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

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 steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.


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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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

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