MySQL 5.5 编译与排错

Posted lyshark

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL 5.5 编译与排错相关的知识,希望对你有一定的参考价值。

**************************************************************************************************
mysql 5.5 编译
**************************************************************************************************

1.安装编译环境

yum install -y gcc gcc-c++

2.安装Ncurses

yum install -y ncurses-devel

tar -xzvf ncurses-6.1.tar.gz

cd ncurses-6.1/

./configure --with-shared \
--without-debug \
--without-ada \
--enable-overwrite

make && make install


3.安装Cmake和Bison

yum install -y cmake bison


4.安装MySQL

groupadd mysql

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

tar -xzvf mysql-5.5.59.tar.gz

cd mysql-5.5.59/

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5 \
-DMYSQL_DATADIR=/usr/local/mysql-5.5/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_DEBUG=0


==============================================================================
上面↑语句的解释

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql #安装位置
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock #指定socket文件位置
-DEXTRA_CHARSETS=all #扩展字符支持
-DDEFAULT_CHARSET=utf8 #默认字符集
-DDEFAULT_COLLATION=utf8_general_ci #默认字符校对
-DWITH_MYISAM_STORAGE_ENGINE=1 #安装myisam存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 #安装innodb存储引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 #安装memory存储引擎
-DWITH_READLINE=1 #支持readline库
-DENABLED_LOCAL_INFILE=1 #启用加载本地数据
-DMYSQL_USER=mysql #指定mysql运行用户
-DMYSQL_TCP_PORT=3306 #指定mysql端口

==============================================================================

make && make install


==================================================
MySQL 5.5 配置
==================================================

1.MySQL目录授权

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


2.拷贝MySQL配置文件

cp -a /usr/local/mysql-5.5/support-files/my-medium.cnf /etc/my.cnf
cp -a /usr/local/mysql-5.5/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld


3.初始化MySQL

cd /usr/local/mysql-5.5/scripts/

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


4.启动MySQL

/etc/init.d/mysqld start

/usr/local/mysql-5.5/bin/mysqld_safe --user=mysql &


5.配置环境变量

echo ‘export PATH=/usr/local/mysql-5.5/bin:$PATH‘ >> /etc/profile

source /etc/profile


6.设置登陆密码

/usr/local/mysql-5.5/bin/mysql_secure_installation


7.设置MySQL开机启动

chkconfig mysqld on

chkconfig --list mysqld

echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &" >> /etc/rc.local


7.登陆MySQL测试

/usr/local/mysql-5.5/bin/mysql -uroot -p

**************************************************************************************************
MySQL-5.5排错
**************************************************************************************************
[问题描述]

描述:MySQL 第一次初始化后无法启动

错误代码:Starting MySQL..The server quit without updating PID file ([FAILED]al/mysql-5.5/data/www.pid).

错误代码:Starting MySQL.180421 12:24:46 mysqld_safe error: log-error set to ‘/usr/local/mysql-5.5/error.log‘, however file don‘t exists. Create writable for user ‘mysql‘.
The server quit without updating PID file (/usr/local/mysql[FAILED]a/www.pid).


[解决策略]

vim /etc/my.cnf

[mysqld]

log-error = /usr/local/mysql-5.5/error.log
datadir = /usr/local/mysql-5.5/data


chown -R mysql.mysql /usr/local/mysql-5.5

./usr/local/mysql-5.5/scripts/mysql_install_db

==============================================================================================



























































以上是关于MySQL 5.5 编译与排错的主要内容,如果未能解决你的问题,请参考以下文章

pam_mysql编译过程排错

pam_mysql编译过程排错

MySQL-5.5 cmake编译安装

mysql5.5的安装与配置(亲测版)

MySQL 5.5单实例 编译安装

PHP编译遇到的问题