最新消息:其实接手服务器,最最最重要的还是要看下数据库、文件备份情况!!!非常重要!!!

mysql 5.1编译安装

application shang 2056浏览 0评论

说明:
mysql 5.1 编译安装

实现:
yum安装相应的库,因为我这台机子还要安装nginx,php,所以以下的库都安装了

# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

 

下载mysql,编译安装

# wget http://dl.gaingreat.com/mysql-5.1.38.tar.gz
#/usr/sbin/groupadd mysql
# /usr/sbin/useradd -s /sbin/nologin -M -g mysql mysql  //添加mysql用户到mysql组,指定sh为/sbin/nologin,无家目录
# tar zxvf mysql-5.1.38.tar.gz
# cd mysql-5.1.38/
# ./configure --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
# make && make install

 
更改mysql安装目录属性,初始化mysql

# mkdir /usr/local/mysql/data
# mkdir /usr/local/mysql/var  //建立这个目录,不然/etc/init.d/mysqld start是会报错,因为默认my.cnf中innodb_data_home_dir和innodb_log_group_home_dir位置为/usr/local/mysql/var,可以修改目录位置也可以新建这个目录
# chown -R mysql:mysql /usr/local/mysql/
# /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql  //这里datadir目录要与下面/etc/my.cnf里的datadir一致,不然会出现starting mysql. error manager of pid-file quit without updating file。具体原因可以通过查看mysql_error.log日志

 

拷贝配置文件到/etc/my.cnf

# cp -f /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf //将skip-locking 转换成skip-external-locking
# sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
# sed -i 's:#innodb:innodb:g' /etc/my.cnf

 

添加开机启动

# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld //添加执行权限
# ln -s /usr/local/mysql/lib/mysql /usr/lib/
# ln -s /usr/local/mysql/insclude/mysql /usr/include/
# chkconfig mysqld on //设置开机启动

 

修改my.cnf,在[mysqld]里面添加

log-error = /usr/local/mysql/mysql_error.log
pid-file = /usr/local/mysql/mysql.pid
datadir = /usr/local/mysql/data

 

启动mysql

# /etc/init.d/mysqld start

 

修改root的密码

# /usr/local/mysql/bin/mysqladmin -u root password 'newpassword'
# /usr/local/mysql/bin/mysql -u root -p  //登陆mysql,删除默认帐号密码
> use mysql;
> delete from user where not (user='root') ;
> delete from user where user='root' and password='';
> drop database test;
> DROP USER ''@'%';  //这条没看出效果
> flush privileges;

 

mysql服务的启动、关闭

# /etc/init.d/mysqld start
# /etc/init.d/mysqld stop

 

附录:
暂空!

原文参考:
Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]
CentOS 6.2 上编译安装 Nginx 1.0.15 + PHP 5.3.16 + MySQL 5.1.62

转载请注明:酷喃|coolnull| » mysql 5.1编译安装

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址