linux 下 源码编译 mysql

我的环境是centos5.4加上mysql5.1.44

 

编译参数可以根据自己的环境定

cd /usr/local/src
tar zxvf mysql-5.1.44.tar.gz
cd mysql-5.1.44
./configure --prefix=/usr/local/mysql \   #mysql的安装路径,如果要卸载的话直接删除这个目录就可以了
--without-debug \  #不要以debug的模式进行编译,
--without-bench \
--enable-thread-safe-client \ #线程的选择
--enable-assembler \
--enable-profiling \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static \
--with-charset=latin1 \
--with-extra-charset=utf8,gbk \
--with-innodb \
--with-csv-storage-engine \
--with-federated-storage-engine \
--with-mysqld-user=mysql \
--without-embedded-server \
--with-server-suffix=-community \
--with-unix-socket-path=/usr/local/mysql/sock/mysql.sock
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
groupadd mysql
useradd -g mysql -d /usr/local/mysql/var mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R mysql var

将MySQL注册为服务,开机自启动:

cp /usr/local/src/mysql-5.1.44/support-files/mysql.server  /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
chkconfig --add mysql
service mysql start

MySQL启动之后,设置root密码:

/usr/local/mysql/bin/mysqladmin -u root -p password newpassword

 

你可能感兴趣的:(thread,mysql,linux,unix,socket)