首页 > 代码库 > centos6.5编译安装mysql5.6.14

centos6.5编译安装mysql5.6.14

1 查看机器上是否装有mysql

rpm -qa | grep mysql

2. 删除已经存在的mysql

rpm -e --nodeps mysql ()强力删除模式)

3.安装编译代码需要的包

 yum -y install gcc gcc-devel gcc-c++ gcc-c++-devel autoconf* automake* zlib* libxml* ncurses-devel ncurses libgcrypt* libtool* cmake openssl openssl-devel bison bison-devel unzip -y

 

4. 解压编译:tar -zxvf mysql-5.6.14.tar.gz
cd mysql-5.6.14

编译安装: mysql5.5以后编译安装使用cmake

 

 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_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

*********************************************************************

如果出现一下错误:
cmake .
-- MySQL 5.5.8
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
 Curses library not found. Please install appropriate package,

     remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
 cmake/readline.cmake:126 (FIND_CURSES)
 cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
 CMakeLists.txt:256 (MYSQL_CHECK_READLINE)


-- Configuring incomplete, errors occurred!

则需要安装 yum -y install ncurses-devel -y   *******而且删除掉 CMakeCache.txt 这个文件。重新再编译一次就OK

5  make && make install

6. 创建mysql用户和mysql组

groupadd mysql

useradd -s /sbin/nologin -g mysql -M mysql

 

-M:不创建家目录

 7.修改/usr/local/mysql权限

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

8.。。

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

 

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

9 启动数据库

 

/usr/local/mysql/bin/mysqld_safe &

10 添加服务,拷贝服务脚本到init.d目录

cp support-files/mysql.server /etc/init.d/mysqld
chkconfig mysql on
/etc/init.d/mysqld   start

11 配置mysql全局使用路径

vim /etc/profile

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

echo $PATH

12: source /etc/profile

使路径生效

 

13 mysql登陆命令

mysql -u root -p

 

修改mysql登陆密码(默认为空)

mysqladmin -u root password ‘123456‘

15查看系统自带表

mysql>show databases;

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

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;                         红色的password为远程访问时,root用户的密码,可以和本地不同。 

  

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

Vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

本文出自 “linux运维初学” 博客,请务必保留此出处http://ht712.blog.51cto.com/9397612/1555060

centos6.5编译安装mysql5.6.14