在CentOS 6.5 平台离线编译安装 MySQL 5.6.22过程记录。
一、下载源码包
二、准备工作
卸载之前本机自带的MYSQL
安装 cmake,编译MYSQL 的工具
yum install cmake
三、解压源码包
tar -zxv -f mysql-5.6.16.tar.gz
cd mysql-5.6.16
四、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_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/jbdata/mysqldb \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1
注:重新运行配置,需要删除CMakeCache.txt文件
执行make
make
安装
make install
五、初始化 mysql 数据库
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
六、复制启动文件
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
七、复制服务启动脚本及加入PATH路径
cp support-files/mysql.server /etc/init.d/mysqld
修改PATH环境变量,让系统可以直接使用mysql的相关命令。
#vim /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
-------------------------------------------------------------------------------------
vim /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
source /etc/profile
八、启动mysql并加入开机启动
service mysqld start
chkconfig --level 35 mysqld on
九、检查mysql是否启动
netstat -tulnp | grep 3306
mysql -u root -p
十、设置mysql密码
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
如有兴趣,也可以看看这篇文章:
以下是小编为您精心挑选的MySQL相关内容,看看是否有所帮助:
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL http://www.linuxidc.com/Linux/2014-05/102351.htm
--------------------------------------分割线 --------------------------------------