CentOS 5.4编译安装MySQL
1、安装编译环境
yum install gcc gcc-c++ autoconf automake ncurses-devel make chkconfig
2、下载,解压缩
wget http://mysql.mirror.tw/Downloads/MySQL-5.1/mysql-5.1.53.tar.gz
tar -xzvf mysql-5.1.53.tar.gz
3、编译
./configure --prefix=/usr/local/mysql --enable-assembler --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=gb2312,gbk,utf8,latin1 --without-debug --with-charset=utf8 --with-collation=utf8_general_ci --with-pthread --enable-static --enable-thread-safe-client
make
make install
4、添加用户,安装数据库
cd /usr/local/mysql/
chown -R mysql:mysql ./
#安装数据库,添加默认mysql配置
./bin/mysql_install_db --user=mysql
cp share/mysql/my-medium.cnf /etc/my.cnf
#下面我们来设置开机启动mysql
cp share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
#之后可以用service mysqld start启动,开机会自动启动
#设置root密码
mysqladmin -u root password ‘new-password’
#删除test数据库、匿名帐户
mysql -u root -p mysql> DROP DATABASE test; [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = ''; [删除匿名帐户]
mysql> FLUSH PRIVILEGES; [重载权限]