烂泥:mysql5.0数据库源码编译安装
本文首发于 烂泥行天下 。 本次实验的mysql、OS相关信息如下: Mysql:5.0.96 OS:centos 32 bit 最近公司要上新的业务,指明数据库使用的是mysql5.0版本。如果是使用rpm包安装的话,那就很简单了。直接使用yum安装即可,命令如下: yum –y install mysql m
本文首发于烂泥行天下。
本次实验的mysql、OS相关信息如下:
Mysql:5.0.96 OS:centos 32 bit
最近公司要上新的业务,指明数据库使用的是mysql5.0版本。如果是使用rpm包安装的话,那就很简单了。直接使用yum安装即可,命令如下:
yum –y install mysql mysql-server
Yum方式安装完毕后,直接启动mysql数据库服务即可。如下图:
这样基本上就可以了。
但是这样安装mysql数据库,没有进行定制。比如mysql数据库的数据文件存储位置。rpm形式安装的数据文件默认位置为/var/lib/mysql。这个我们可以通过mysql的配置文件查看所得,如下图:
实际的情况是,我们新的业务要求mysql数据库的数据文件需要单独进行存放,这个使用rpm形式就不太容易达到要求。所以打算使用源码进行编译安装,而且自己也没有对mysql数据库进行源码安装过。刚好趁这次机会学习如何对mysql数据库进行源码安装。
首先,在相应的网站下载mysql的安装包。为什么说是相应的网站,而不是mysql的官网。因为现在在官网无法下载到5.0版本的,只能下载到5.5以上的版本。我现在是在这个网站下载的:http://download.mysql.cn/src/
下载完毕上传到服务器上,具体如何上传你可以使用winscp、FTP。或者也可以使用lrzsz这个软件。
我现在使用的就是lrzsz这个软件,如果你的服务器没有安装的话,可以通过:
yum –y install lrzsz
进行安装,如下图:
rz 是上传的命令,sz是下载的命令。
我们现在使用日志命令把mysql的安装包,上传到服务器上,如下图:
Mysql安装包已经上传完毕,那么我们现在进行安装mysql之前的工作。
安装mysql编译所需要的工具包,如下图:
yum -y install gcc gcc-c++ ncurses-devel
工具包安装完毕后,我们来新建相关的用户。第一个用户ilanni,用来安装mysql使用。第二个用户是mysql,用来运行mysql的。如下图:
把mysql安装包移动到ilanni用户的家目录下,并解压,如下图:
以上工作是前提工作,做完后。我们现在进入mysql-5.0.96目录开始安装mysql。
首先编译mysql数据库,如下图:
./configure --prefix=/usr/local/mysql 其中/usr/local/mysql为mysql数据库的安装位置。
可以看到没有报错,那我们开始make,如下图:
Make过程比较慢,我这边大约10分钟左右。
Make终于完毕了,通过上图可以没有报错。
下面开始make install,如下图:
Make install还是比较快的,可以看到没有报错。
Mysql已经安装完毕,下面开始进行相关的配置。
还是在该安装目录下,如下图:
复制support-files目录下的my-medium.cnf到/etc/下作为mysql的配置文件:
cp support-files/my-medium.cnf /etc/my.cnf
复制support-files目录下的mysql.server到/etc/init.d/目录下作为mysql的启动文件
现在我们来启动下使用/etc/init.d/mysqld启动mysql 试下,如下图:
可以看到系统提示我们,没有执行该脚本的权限。而mysqld脚本的权限,看下图:
可以很明显的看到目前该脚本的权限为744,根本没有执行权限。
现在更改该脚本的权限,如下图:
Ok,该文件的权限修改完毕后,我们来初始化mysql数据库。在文章的开头我就说了,我现在要把mysql的数据文件存放在/data目录下。
首先要创建/data目录,并修改该目录的所属用户及用户组。如下图:
修改完毕后,我们还需要修改/usr/local/mysql的所属用户及用户组,如下图:
以上修改完毕后,我们还需要修改mysql的配置文件。主要是要在配置文件中加入目前自己定义数据文件位置,如下图:
以上所有的修改进行完毕后,我们在执行mysql安装目录scripts下mysql_install_db文件,如下图:
./scripts/mysql_install_db --user=mysql 中的--user=mysql一定要有。
我们来查看mysql初始化的结果,查看/data目录,如下图:
可以看到mysql的默认数据mysql及test都在里面。
现在我们来启动mysql看看实际的情况,如下图:
/etc/init.d/mysqld start
如果要把mysql开机启动,可以使用chkconfig命令。如下图:
如果你想在如何目录下直接mysql命令,需要把/usr/local/mysql/bin路径加入到全局设置/etc/profile文件中,如下图:
Ok,到此mysql数据库就安装完毕。
如果mysql客户端连接,mysql服务比较慢的话。我们需要在my.cnf文件中加入skip-name-resolve,如下:
PS:有关本次实验使用的命令如下,在执行过程中建议尽量按照命令的顺序进行操作:
yum -y install gcc gcc-c++ ncurses-devel
tar xf mysql-5.0.22.tar.gz
useradd ilanni
useradd -s /sbin/nologin mysql
cd /home/ilanni/mysql-5.0.22
./configure --prefix=/usr/local/mysql
make
make install
cp /home/ilanni/mysql-5.0.96/support-files/my-medium.cnf /etc/my.cnf
cp /home/ilanni/mysql-5.0.96/support-files/mysql.server /etc/init.d/mysqld
chmod -R 755 /etc/init.d/mysqld
chown -R mysql:mysql /usr/local/mysql
mkdir /data
chown -R mysql:mysql /data
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql
/etc/init.d/mysqld start
echo PATH=$PATH:/usr/local/mysql/bin/ >>/etc/profile
tail -10 /etc/profile
source /etc/profile

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



Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Detailed steps to install Go language on Win7 computer Go (also known as Golang) is an open source programming language developed by Google. It is simple, efficient and has excellent concurrency performance. It is suitable for the development of cloud services, network applications and back-end systems. . Installing the Go language on a Win7 computer allows you to quickly get started with the language and start writing Go programs. The following will introduce in detail the steps to install the Go language on a Win7 computer, and attach specific code examples. Step 1: Download the Go language installation package and visit the Go official website

Essential PHP programs: Install these to run smoothly! PHP is a popular server-side scripting language that is widely used to develop web applications. To successfully run a PHP program, you first need to install some necessary software and tools on the server. In this article, we will introduce the software and tools that must be installed, along with specific code examples to help you run PHP programs smoothly. 1. PHP interpreter The core of the PHP program is the PHP interpreter, which is responsible for parsing and executing PHP code. To install the PHP interpreter, you can follow

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to download 360 Secure Browser on your computer? It is a very secure web browser software. This browser is very rich in functions and very simple to operate. Using 360 Secure Browser to browse the web can protect user privacy and security very well. Many people like to use this browser. Browser office, but many people still don’t know how to download and install 360 Secure Browser on their computers. This article will give you a detailed introduction to the installation process of the 360 Safe Browser PC version, hoping to help you solve the problem. Overview of the installation process under the computer version of 360 Secure Browser 1. On the computer’s main page, find “360 Software Manager” and enter (as shown in the picture). 2. Open 360 Software Manager and find the search box (as shown in the picture). 3. Click Search
