©
本文档使用
php.cn手册 发布
此种方式适合所有MySQL5.0.xx-5.1.xx产品系列,是最常规的编译方式。
常规方式编译安装MySQL就是延续早起MySQL的3部曲安装方式,即
./configure make make install
useradd mysql -s /sbin/nologin
yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake curl freetype libjpeg-turbo libjpeg-turbo-devel openjpeg-libs libpng gd ncurses
./configure \ --prefix=/usr/local/mysql \ --with-unix-socket-path=/var/lib/mysql/mysql.sock \ --localstatedir=/usr/local/mysql/data \ --enable-assembler \ --enable-thread-safe-client \ --with-mysqld-user=mysql \ --with-bid-tables \ --with-debtg \ --with-pthread \ --with-extra-charsets=complex \ --with-readline \ --with-ssl \ --with-embedded-server \ --enable-local-infile \ --with-plugins=partition,innobase \ --with-mysqld-ldflags=-all-static \ --with-client-ldflags=-all-static \
上面的编译完成后,执行下面的命令。
make && make install
chown -R mysql.mysql /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cd /usr/local/src/mysql-5.1.59/support-files cp mysql.server /etc/rc.d/init.d/mysqld #使用默认配置文件 cp my-small.cnf /etc/my.cnf #让chkconfig管理mysqld服务 chkconfig --add mysqld #开机启动 chkconfig mysqld on
service mysqld start
将mysql的bin加入到path中
cd ~ #把path添加到当前用户目录的bashrc中,如果需要全局设定,请修改`/etc/profile` vi .bashrc #加入以下内容 PATH=/usr/local/mysql/bin:$PATH source /etc/profile
mysqladmin -uroot password 'aaaaaa' # 在bash命令行执行`
SHOW VARIABLES LIKE 'character%'
修改mysql的my.cnf文件
[client] default-character-set=utf8 [mysqld] character-set-server=utf8 pid-file=/var/lib/mysql/mysqld.pid [mysql] default-character-set=utf8 [mysqld_safe] log-error=/var/lib/mysql/mysql_error.err