一、编译安装MysqL前的准备工作
安装编译源码所需的工具和库()
第一种方式:
#rpm -qa | grep gcc-c++
#rpm -qa | grep ncurses
#rpm -qa | grep cmake
#rpm -qa | grep perl
第二种方式:
#yum -y install gcc-c++ ncurses cmake perl
安装cmake,从http://www.cmake.org下载源码并编译安装
tar-xzvfcmake-2.8.10.2.tar.gz cdcmake-2.8.10.2 ./bootstrap ; make ; makeinstall cd~安装ncurse 从http://download.chinaunix.net/ 下载源码并编译安装
tar-xzvf<span style="font-family: 'microsoft yahei';">ncurses-5.7.tar.gz</span> cd<span style="font-family: 'microsoft yahei';">ncurses-5.7</span> ./configure ; make ; makeinstall cd~
二、编译安装MysqL
# 新建数据库执行文件目录
#mkdir -p /usr/local/MysqL
# 新建数据库数据文件目录
#mkdir -p /db/MysqL/data
# 修改目录拥有者
chown -R MysqL:MysqL /usr/local/MysqL
chown -R MysqL:MysqL /db/MysqL/data
chown -R MysqL:MysqL /usr/local/MysqL/.
chown -R MysqL:MysqL /db/MysqL/data/.
# 编辑PATH搜索路径
#vi /etc/profile
Append these 2 lines to the end of the file(将下面两行代码添加文件结尾):
PATH=/usr/local/MysqL/bin:/usr/local/MysqL/lib:$PATH
export PATH
# 生效PATH搜索路径
#source /etc/profile
# 进入源码压缩包下载目录
#cd /usr/src
# 解压缩源码包
#tar -zxv -f MysqL-5.6.16.tar.gz
# 进入解压缩源码目录
#cd MysqL-5.6.16
#从MysqL5.5起,MysqL源码安装开始使用cmake了,执行源码编译配置脚本。
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL \
-DMysqL_UNIX_ADDR=/usr/local/MysqL/MysqL.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMysqL_DATADIR=/db/MysqL/data \
-DMysqL_USER=MysqL \
-DMysqL_TCP_PORT=3306
# 编译源码,这一步时间会较长,耐心等待。
#make
# 安装
#make install
# 复制配置文件
#cp /usr/local/MysqL/support-files/my-default.cnf /etc/my.cnf
# 进入安装路径
#cd /usr/local/MysqL
# 执行配置脚本
#scripts/MysqL_install_db --user=MysqL --datadir=/db/MysqL/data
# 复制服务启动脚本
#cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqL
# 启动MysqL服务
#service MysqL start
# 设置开机自动启动服务
#chkconfig MysqL on
----------------------------------------MysqL 已经安装完毕---------------------------------------------------------------------------------------------
进入MysqL可执行目录bin(/usr/local/MysqL/bin)
# cd /usr/local/MysqL/bin
# ls -a
#./MysqL
MysqL> use MysqL;
MysqL> desc user; MysqL> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力 MysqL> update user set Password = password('123456') where User='root'; //设置root用户密码 MysqL> select Host,User,Password from user where User='root'; MysqL> flush privileges; MysqL> exit