CentOS 6.5下编译安装MySQL 5.6.20
CentOS 6.5下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.20。
概述:
CentOS 6.5下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.20。
正文:
一:卸载旧版本
使用下面的命令检查是否安装有MySQL Server
rpm -qa | grep mysql有的话通过下面的命令来卸载掉
rpm -e mysql //普通删除模式
rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除二:安装MySQL
安装编译代码需要的包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel下载MySQL 5.6.14
wget
tar xvf mysql-5.6.20.tar.gz
cd mysql-5.6.20编译安装
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLE_DOWNLOADS=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install编译的参数可以参考。
整个过程需要30分钟左右……漫长的等待
三:配置MySQL
设置权限
使用下面的命令查看是否有mysql用户及用户组
cat /etc/passwd 查看用户列表
cat /etc/group 查看用户组列表如果没有就创建
groupadd mysql
useradd -g mysql mysql修改/usr/local/mysql权限
chown -R mysql:mysql /usr/local/mysql修改/usr/local/mysql权限
初始化配置
进入安装路径
cd /usr/local/mysql进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/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的正确配置,造成无法启动。
启动MySQL
添加服务,拷贝服务脚本到init.d目录,并设置开机启动
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start --启动MySQL配置用户
MySQL启动成功后,root默认没有密码,我们需要设置root密码。
设置之前,我们需要先设置PATH,要不不能直接调用mysql
修改/etc/profile文件,在文件末尾添加
PATH=/usr/local/mysql/bin:$PATH
export PATH关闭文件,运行下面的命令,让配置立即生效
source /etc/profile现在,我们可以在终端内直接输入mysql进入,mysql的环境了
执行下面的命令修改root密码
mysql -uroot
mysql> SET PASSWORD = PASSWORD('123456');若要设置root用户可以远程访问,执行
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;红色的password为远程访问时,root用户的密码,可以和本地不同。
配置防火墙
防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口
打开/etc/sysconfig/iptables
在“-A INPUT –m state --state NEW –m tcp –p –dport 22 –j ACCEPT”,下添加:
-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:
service iptables restart OK,一切配置完毕,你可以访问你的MySQL了~
--------------------------------------分割线 --------------------------------------
Ubuntu 14.04下安装MySQL
《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL
Ubuntu 14.04下搭建MySQL主从服务器
Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群
Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb
MySQL-5.5.38通用二进制安装
--------------------------------------分割线 --------------------------------------
还有一篇见下一页:

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

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

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

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

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]

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