Version: MySQL-5.5.31.tar.gz
创建运行MYSQL数据库的系统用户、解包、编译前配置、编译、安装
[root@SRV ~]# grep "mysql"/etc/passwd
mysql:x:500:501::/home/mysql:/sbin/nologin
[root@SRV src]# yum install cmake ncurses ncurses-develbison
[root@SRV src]# tar zxvfmysql-5.5.31.tar.gz
[root@SRV src]# cd mysql-5.5.31
[root@SRV mysql-5.5.31]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql2 -DSYSCONFDIR=/etc-DMYSQL_DATADIR=/data/mysql2-DMYSQL_UNIX_ADDR=/tmp/mysql3307.sock -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3307
[root@SRV mysql-5.5.31]#make &&make install
如果想清理此前编译所生成的文件:# rm -rf CMakeCache.txt
建立配置文件
[root@SRV mysql-5.5.31]# cpsupport-files/my-medium.cnf /etc/my2.cnf
[root@SRV mysql-5.5.31]#
创建数据存放目录及初始化数据库
[root@SRV mysql-5.5.31]# mkdir -p/data/mysql2
[root@SRV mysql-5.5.31]# cd/usr/local/mysql2/
[root@SRV mysql2]#./scripts/mysql_install_db --basedir=/usr/local/mysql2 --datadir=/data/mysql2/--user=mysql
[root@SRV ~]# chown -R mysql.mysql/data/mysql2/
调整lib库路经及设置MySQL程序的执行路经:
[root@SRV ~]# echo"/usr/local/mysql2/lib/" >> /etc/ld.so.conf
[root@SRV ~]# ldconfig
[root@SRV ~]# echo"PATH=$PATH:/usr/local/mysql2/bin/" >> /etc/profile
[root@SRV ~]# source /etc/profile
[root@SRV ~]# echo $PATH
.:/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/jdk1.6.0_43/bin:/root/bin:/usr/local/mysql2/bin/
MySQL的启动、关闭、登陆:
启动: [root@SRV ~]#/usr/local/mysql2/bin/mysqld_safe --defaults-file=/etc/my2.cnf --datadir=/data/mysql2 --user=mysql &
关闭: [root@SRV ~]#/usr/local/mysql2/bin/mysqladmin -uroot -S /tmp/mysql3307.sock -p shutdown
登陆: [root@SRV ~]# /usr/local/mysql2/bin/mysql-uroot -S /tmp/mysql3307.sock -P3307 -p
设置MySQL的root密码:
[root@SRV ~]#/usr/local/mysql2/bin/mysqladmin -uroot password 'server1' -S /tmp/mysql3307.sock
[ERROR ]
130812 19:55:31 mysqld started
130812 19:55:31 [ERROR] Can't findmessagefile '/usr/share/mysql/english/errmsg.sys'
130812 19:55:31 [ERROR] Aborting
130812 19:55:31 mysqld ended
>> [root@SRV1 ~]# cp/usr/local/src/mysql-5.5.28/sql/share/english/errmsg.sys/usr/share/mysql/english/