下面是在CentOS下编译安装MySQL出现错误的解决方案攻略:
1. 安装编译所需的依赖库
在进行MySQL的编译安装前,需要安装一些必要的依赖库。执行以下命令安装:
yum install -y gcc gcc-c++ ncurses-devel cmake autoconf libtool libaio
2. 下载MySQL的源码包
下载MySQL的源码包,在官网上选择合适的版本进行下载,可以使用wget命令,例如:
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.29.tar.gz
3. 解压源码包并进行配置
解压源码包,并进入源码包所在目录,执行以下命令进行配置:
tar -zxvf mysql-5.7.29.tar.gz
cd mysql-5.7.29
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=/usr/local/boost \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system
其中,-DCMAKE_INSTALL_PREFIX指定了MySQL安装路径,-DWITH_BOOST指定了Boost库的安装路径,-DSYSCONFDIR指定了配置文件的路径,其他的是一些常用配置项。
4. 进行编译和安装
执行以下命令进行编译和安装:
make && make install
5. 配置MySQL
执行以下命令进行配置:
cd /usr/local/mysql
cp support-files/my-default.cnf /etc/my.cnf
bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
6. 启动MySQL
执行以下命令启动MySQL:
bin/mysqld_safe --user=mysql &
如果出现以下错误:
Starting mysqld daemon with databases from /usr/local/mysql/data
2018-04-12T10:02:14.067788Z mysqld_safe Logging to '/usr/local/mysql/data/servername.err'.
2018-04-12T10:02:14.367451Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
2018-04-12T10:02:14.399128Z mysqld_safe mysqld from pid file /usr/local/mysql/data/servername.pid ended
则需要执行以下命令安装相应的库:
yum install -y ncurses-devel
如果出现以下错误:
Starting mysqld daemon with databases from /usr/local/mysql/data
2018-04-12T10:06:47.573063Z mysqld_safe Logging to '/usr/local/mysql/data/servername.err'.
2018-04-12T10:06:47.874128Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2018-04-12T10:06:47.942250Z mysqld_safe mysqld from pid file /usr/local/mysql/data/servername.pid ended
则需要查看错误日志文件,命令如下:
cat /usr/local/mysql/data/servername.err
根据错误日志文件中的提示进行排错。
至此,CentOS下编译安装MySQL报错的解决方案攻略完成。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:centos下编译安装mysql报错解决方案 - Python技术站