Home Database Mysql Tutorial mysql在linux上的安装之二(mysql源码安装)_MySQL

mysql在linux上的安装之二(mysql源码安装)_MySQL

Jun 01, 2016 pm 01:02 PM
Source code


1.下载相应的mysql安装源码包
地址为:http://dev.mysql.com/downloads/mysql/5.1.html

2.如果以前安装过则卸载无用过旧的已安装的mysql
由于很多linux发行版,都预装了相应的mysql,一般都是rpm形式的安装,且mysql的版本都是比较低的(这个可能是由于兼容性测试的考虑吧)。因此在自己亲自安装mysql之前,请先卸载这些过旧的mysql,保证我们系统的“纯净”。
使用如下命令查询系统中安装的mysql:
rpm -qa|grep mysql
此命令会模糊匹配软件名有mysql的rpm安装包,列出来的这些都可以把他们删掉,一次性删掉,可使用如下的一个脚本命令:
for i in `rpm -qa | grep "mysql"`; do rpm -e --allmatches $i; done
执行完上面命令后,如果还有顽固分子没有被删除,那就一个一个利用下面的命令来删除:
rpm -e --allmatches packet-name
如果发现循环依赖问题,那么packet-name就列出这些循环依赖的安装包,一次性全部删除,如:
[root@test root]# rpm -e --allmatches mysql


安装源代码版本的MySQL
3.添加mysql用户组
groupadd mysql

4.添加mysql用户,并指定到mysql用户组
useradd -g mysql mysql

5.解压缩mysql-version.tar.gz
gunzip
6.安装mysql
cd mysql-VERSION
./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charsets=armscii8,ascii,big5,cp1250,cp1251,cp1256,cp1257,cp850,cp852,cp866,cp932,dec8,eucjpms,euckr,gb2312,gbk,geostd8,greek,hebrew,hp8,keybcs2,koi8r,koi8u,latin1,latin2,latin5,latin7,macce,macroman,sjis,swe7,tis620,ucs2,ujis,utf8 --with-plugins=innodb_plugin
make
make install

7.复制配置文件
shell> cp support-files/my-medium.cnf /etc/my.cnf

8.执行mysql系统数据库初始化脚本
cd /usr/local/mysql
bin/mysql_install_db --user=mysql

9.设定mysql安装目录权限,设置owner为mysql
chown -R mysql var
chgrp -R mysql .

10.启动mysql应用
/usr/local/mysql/bin/mysqld_safe --user=mysql &

11.设置root密码(数据库的DBA)
bin/mysqladmin -u root password ‘root’

12.登录mysql
bin/mysql -uroot -p
Enter password:
登录成功会看到:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 229
Server version: 5.1.40-log MySQL Community Server (GPL)

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

mysql>

这时mysql已经装好了,可以查看数据库了,但在正式使用数据库开发与部署的时候还需要做一些工作:

1.设定配置文件my.cnf

按照需求copy my-***.cnf到/etc/my.cnf

2.修改默认字符集utf8

(1).[client]下加入default-character-set=utf8
(2).[mysqld]下加入default-character-set=utf8

#不改动存储引擎的话,3、4步可以略过
3.启动InnoDB引擎的方法如下:
1)关闭mysql的服务
2)修改my.ini
将default-storage-engine=INNODB前的注释(#)去掉
将skip-innodb这行注释(加上#)

4.配置innodb参数
1).找到# Uncomment the following if you are using InnoDB tables
去掉innodb_*下的所有#

2).如果安装mysql的目录不是默认的,则需要修改
# mysql 默认安装目录为 /usr/local/mysql/
# mysql 默认表空间目录安装目录为 /usr/local/mysql/var/

innodb_data_home_dir=/usr/local/database/mysql/var/
innodb_log_group_home_dir=/usr/local/database/mysql/var/
3).保存后重启mysql服务。

5.设置系统服务

让linux启动的时候就启动mysql服务
shell> cd /usr/local/mysql/
shell> cp support-files/mysql.server /etc/init.d/mysql
shell> chmod 777 /etc/init.d/mysql
shell> chkconfig --add mysql
shell> chkconfig --level 35 mysql on

6.重启MySQL服务
shell> service mysql restart
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Application practice of Python in software source code protection Application practice of Python in software source code protection Jun 29, 2023 am 11:20 AM

As a high-level programming language, Python language is easy to learn, easy to read and write, and has been widely used in the field of software development. However, due to the open source nature of Python, the source code is easily accessible to others, which brings some challenges to software source code protection. Therefore, in practical applications, we often need to take some methods to protect Python source code and ensure its security. In software source code protection, there are a variety of application practices for Python to choose from. Below are some common

How to display the source code of PHP code in the browser without being interpreted and executed? How to display the source code of PHP code in the browser without being interpreted and executed? Mar 11, 2024 am 10:54 AM

How to display the source code of PHP code in the browser without being interpreted and executed? PHP is a server-side scripting language commonly used to develop dynamic web pages. When a PHP file is requested on the server, the server interprets and executes the PHP code in it and sends the final HTML content to the browser for display. However, sometimes we want to display the source code of the PHP file directly in the browser instead of being executed. This article will introduce how to display the source code of PHP code in the browser without being interpreted and executed. In PHP, you can use

Website to view source code online Website to view source code online Jan 10, 2024 pm 03:31 PM

You can use the browser's developer tools to view the source code of the website. In the Google Chrome browser: 1. Open the Chrome browser and visit the website where you want to view the source code; 2. Right-click anywhere on the web page and select "Inspect" or press the shortcut key Ctrl + Shift + I to open the developer tools; 3. In the top menu bar of the developer tools, select the "Elements" tab; 4. Just see the HTML and CSS code of the website.

How to view the source code of tomcat in idea How to view the source code of tomcat in idea Jan 25, 2024 pm 02:01 PM

Steps to view tomcat source code in IDEA: 1. Download Tomcat source code; 2. Import Tomcat source code in IDEA; 3. View Tomcat source code; 4. Understand the working principle of Tomcat; 5. Precautions; 6. Continuous learning and updating ; 7. Use tools and plug-ins; 8. Participate in the community and contribute. Detailed introduction: 1. Download the Tomcat source code. You can download the source code package from the official website of Apache Tomcat. Usually these source code packages are in ZIP or TAR format, etc.

Can vue display source code? Can vue display source code? Jan 05, 2023 pm 03:17 PM

Vue can display the source code. The method for viewing the source code in Vue is: 1. Obtain Vue through "git clone https://github.com/vuejs/vue.git"; 2. Install dependencies through "npm i"; 3. Through " npm i -g rollup" to install rollup; 4. Modify the dev script; 5. Debug the source code.

PHP source code error: solving index error problem PHP source code error: solving index error problem Mar 10, 2024 am 11:12 AM

PHP source code error: To solve the index error problem, specific code examples are needed. With the rapid development of the Internet, developers often encounter various problems when writing websites and applications. Among them, PHP is a popular server-side scripting language, and its source code errors are one of the problems that developers often encounter. Sometimes, when we try to open the index page of a website, various error messages will appear, such as "InternalServerError", "Unde

A comprehensive guide to learning and applying golang framework source code A comprehensive guide to learning and applying golang framework source code Jun 01, 2024 pm 10:31 PM

By understanding the Golang framework source code, developers can master the essence of the language and expand the framework's functions. First, get the source code and become familiar with its directory structure. Second, read the code, trace the execution flow, and understand dependencies. Practical examples show how to apply this knowledge: create custom middleware and extend the routing system. Best practices include learning step-by-step, avoiding mindless copy-pasting, utilizing tools, and referring to online resources.

Golang framework source code analysis and optimization Golang framework source code analysis and optimization Jun 02, 2024 pm 04:54 PM

This article explores the source code analysis and optimization of the Go framework. The source code structure includes four main packages, involving core framework logic, request context, data binding and response rendering. Optimization techniques include: 1. Use routing trees to optimize route processing to significantly increase route lookup speed. 2. Use middleware for caching and compression to reduce server load and response time. 3. Avoid performing time-consuming operations in callbacks to maintain high responsiveness. 4. Enable logging and analyze slow requests to identify performance bottlenecks. 5. Update framework versions regularly to take advantage of the latest performance improvements.

See all articles