useradd -M -s /sbin/nologin -u 49 mysql
执行过程:
[root@Mysql ~]# useradd -M -s /sbin/nologin -u 49mysql
[root@Mysql ~]# cat /etc/passwd | grep mysql
mysql:x:49:500::/home/mysql:/sbin/nologin
参数说明:
-M 不创建mysql家目录
-s 指定mysql登录的shell环境,nologin表示不登录shell
-u 指定mysql用户的uid
[root@Mysql ~]# rpm -q mysqld package mysqld is not installed [root@Mysql ~]# yum install ncurses ncurses-devel -y
cd /usr/src/ wget http://down1.chinaunix.net/distfiles/mysql-5.1.56.tar.gz tar zxf mysql-5.1.56.tar.gz cd mysql-5.1.56 ./configure--prefix=/usr/local/mysql-5.1.56 --with-unix-socket-path=/usr/local/mysql-5.1.56/tmp/mysql.sock --with-charset=utf8--with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312--localstatedir=/usr/local/mysql-5.1.56/data --enable-assembler--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-thread-safe-client--with-mysqld-user=mysql --with-big-table --without-debug --with-pthread make && make install
执行过程:
[root@Mysql src]# tar zxf mysql-5.1.56.tar.gz
[root@Mysql src]# cd mysql-5.1.56
[root@Mysql mysql-5.1.56]# ./configure --prefix=/usr/local/mysql-5.1.56--with-unix-socket-path=/usr/local/mysql-5.1.56/tmp/mysql.sock --with-charset=utf8--with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312--localstatedir=/usr/local/mysql-5.1.56/data --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static--enable-thread-safe-client --with-mysqld-user=mysql --with-big-table--without-debug --with-pthread
[root@Mysql mysql-5.1.56]# make && makeinstall
参数解释:
./configure--prefix=/usr/local/mysql-5.1.56 #指定安装路径
--with-unix-socket-path=/usr/local/mysql-5.1.56/tmp/mysql.sock \ #指定mysql.sock位置
--with-charset=utf8 #指定mysql默认的字符集
--with-collation=utf8_general_ci
--with-extra-charsets=gbk,gb2312 #指定mysql可扩展的字符集
--localstatedir=/usr/local/mysql-5.1.56/data #指定mysql 数据库文件存放的位置
--enable-assembler #允许使用汇编模式(优化性能)
--with-mysqld-ldflags=-all-static #服务器使用静态库(优化性能)
--with-client-ldflags=-all-static #客户端使用静态库(优化性能)
--enable-thread-safe-client #以线程方式编译mysql
--with-mysqld-user=mysql #指定mysql运行的用户
--with-big-tables #支持大表格式
--without-debug #使用非debug模式
--with-pthread #强制使用pthread线程序库编译
配置完成之后,没有error提示,出现thanke you for choosemysql即可执行make 编译安装,最后make install 安装到系统
4.1生成mysql 的主配置文件 my.cnf
[root@Mysql mysql-5.1.56]# cp -f/usr/src/mysql-5.1.56/support-files/my-medium.cnf /etc/my.cnf cp: overwrite `/etc/my.cnf‘? y #覆盖掉原来的即可
4.2生成mysql的启动文件,便于管理
[root@Mysql mysql-5.1.56]# cp -f/usr/src/mysql-5.1.56/support-files/mysql.server /etc/init.d/mysqld [root@Mysql mysql-5.1.56]# chmod a+x/etc/init.d/mysqld [root@Mysql mysql-5.1.56]# chkconfig --add mysqld [root@Mysql mysql-5.1.56]# chkconfig mysqld on
4.3链接mysql执行路径
[root@Mysql ~]# ln -sf /usr/local/mysql-5.1.56/bin/*/usr/local/bin/ [root@Mysql ~]# ln -sf/usr/local/mysql-5.1.56/lib/mysql/* /usr/lib [root@Mysql ~]# ln -sf/usr/local/mysql-5.1.56/include/mysql/* /usr/include/ [root@Mysql ~]# ln -sf /usr/local/mysql-5.1.56//usr/local/mysql
4.5初始化数据库
[root@Mysql ~]# cd /usr/local/mysql/bin/ [root@Mysql bin]# ./mysql_install_db --user=mysql--basedir=/usr/local/mysql-5.1.56/ --datadir=/usr/local/mysql-5.1.56/data 当出现两个OK时,表示初始化成功
4.6.设置权限
[root@Mysql bin]# chown -R root:mysql/usr/local/mysql-5.1.56/ [root@Mysql bin]# chown -R mysql/usr/local/mysql-5.1.56/data/
4.7.启动mysql
[root@Mysql bin]# service mysqld start Starting MySQL SUCCESS! [root@Mysql bin]# netstat -anput | grep mysql tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 42386/mysqld
本文出自 “Study-Everyday” 博客,请务必保留此出处http://studys.blog.51cto.com/9736817/1599107
原文地址:http://studys.blog.51cto.com/9736817/1599107