首页 > 代码库 > mysql编译安装
mysql编译安装
源码安装mysql,按文档执行一遍
下载源码包
tar zxf 进入目录
./configure --prefix=/usr/local/mysql --enable-assembler &&make && make install
创建mysql用户,chown -R mysql.mysql /usr/local/mysql/
然后数据库初始化
/usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=./var --basedir=/usr/local/mysql/
重新
然后启动
/usr/local/mysql/bin/mysqld_safe --user=mysql&
配置源码mysql为系统服务:
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
service mysqld restart
mysql5.5
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0
make && make install
创建mysql用户,chown -R mysql.mysql /usr/local/mysql/
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=./var --basedir=/usr/local/mysql/
这一步初始化数据库系统,初始化数据目录和根目录
nohup /usr/local/mysql55/bin/mysqld_safe --user=mysql & 服务器后台启动mysql
ps -ef |grep mysql 看看开成功没
还不行,要把主机名写在hosts文件里,保证主机名能ping通
然后就可以mysql了
mysql编译安装