Home Database Mysql Tutorial CentOS6.4下编译安装MySQL5.6.16_MySQL

CentOS6.4下编译安装MySQL5.6.16_MySQL

May 31, 2016 am 08:48 AM

CentOS6CentOS

一、卸载旧版本MySql

1、rpm卸载:

1> 检查安装包:

rpm -qa | grep mysql

2> 普通删除:

rpm -e mysql-5.6.16.rpm

3> 强力删除。如果使用上面命令删除时,提示有依赖的其他文件,则使用该命令可以对其进行强力删除。

rpm -e --nodeps mysql-5.6.16.rpm

2、tar卸载:

1> 删除临时文件:

make clean

2> 卸载

make uninstall

3> 删除解压文件

rm -rf 文件夹

3、yum卸载:

1> 卸载一个软件:

yum remove package_name

2> 卸载多个:

yum remove package_name1 package_name2 package_name3

二、安装MySql

1、安装编译器gcc-c++:

yum -y install make gcc-c++ cmake bison-devel ncurses-devel

2、下载并解压:

1> 下载tar安装包:

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz

2> 解压安装包:

tar -xzvf mysql-5.6.16.tar.gz

3> 给解压文件重命名:

mv mysql-5.6.16 mysql

3、编译安装:

1、进入安装目录:

cd mysql

2、配置参数:

cmake /

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql /

-DMYSQL_DATADIR=/home/mysql/data /

-DSYSCONFDIR=/etc

-DWITH_MYISAM_STORAGE_ENGINE=1 /

-DWITH_INNOBASE_STORAGE_ENGINE=1 /

-DWITH_MEMORY_STORAGE_ENGINE=1 /

-DWITH_READLINE=1 /

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock /

-DMYSQL_TCP_PORT=3306 /

-DENABLED_LOCAL_INFILE=1 /

-DWITH_PARTITION_STORAGE_ENGINE=1 /

-DEXTRA_CHARSETS=all /

-DDEFAULT_CHARSET=utf8 /

-DDEFAULT_COLLATION=utf8_general_ci

3> 编译安装:

make && make install

编译的参数可以参考http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html。

整个过程需要30分钟左右……漫长的等待

三、配置MySql:

1、设置权限:

1> 使用下面的命令查看是否有mysql用户及用户组:

cat /etc/passwd 查看用户列表

cat /etc/group 查看用户组列表

2> 如果没有就创建:

groupadd mysql

useradd -g mysql mysql

3> 修改/usr/local/mysql权限:

chown -R mysql:mysql /usr/local/mysql

2、初始化配置:

1> 进入安装路径

cd /usr/local/mysql

2、进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表:

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql/data --user=mysql

注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置!注意:在CentOS 6.4版操作系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。

3、启动MySQL:

1> 添加服务,拷贝服务脚本到init.d目录,并设置开机启动并生效(可以不设置)

cp support-files/mysql.server /etc/init.d/mysql

chkconfig mysql on

2> 启动MySql:

service mysql start --启动MySQL

4、配置用户

MySQL启动成功后,root默认没有密码,我们需要设置root密码。

设置之前,我们需要先设置PATH,要不不能直接调用mysql

1> 修改/etc/profile文件,在文件末尾添加

PATH=/usr/local/mysql/bin:$PATH

export PATH

2> 使环境变量配置文件立即生效:

source /etc/profile

3> 在终端内直接输入mysql进入mysql的环境,执行下面的命令修改root密码:

mysql -uroot

mysql> SET PASSWORD = PASSWORD('123456');

4> 若要设置root用户可以远程访问,执行

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;

红色的password为远程访问时,root用户的密码,可以和本地不同。

5、配置防火墙:(如果不使用防火墙,这一步可以不用)

1> 防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口

打开/etc/sysconfig/iptables

在“-A INPUT

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)

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

How do you represent relationships using foreign keys? How do you represent relationships using foreign keys? Mar 19, 2025 pm 03:48 PM

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

How do you create indexes on JSON columns? How do you create indexes on JSON columns? Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? Mar 18, 2025 pm 12:00 PM

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)

See all articles