[root@cmakemysql software]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)
[root@cmakemysql software]# uname -r
2.6.32-504.el6.x86_64
[root@cmakemysql software]# uname -m
x86_64
1.
解压cmake
tar -xvf cmake-2.8.8.tar.gz
2.
进入
[root@cmakemysql cmake-2.8.8]# pwd
/u01/software/cmake-2.8.8
[root@cmakemysql cmake-2.8.8]# ./configure
运行后会出现下面的信息
-- Build files have been written to: /u01/software/cmake-2.8.8
---------------------------------------------
CMake has bootstrapped. Now run gmake.
3.[root@cmakemysql cmake-2.8.8]# gmake && gmake install
4.
[root@cmakemysql cmake-2.8.8]# cd ..
[root@cmakemysql software]# yum -y install ncurses-devel.x86_64
5.
[root@cmakemysql software]# groupadd mysql
[root@cmakemysql software]# useradd mysql -s /sbin/nologin -M -g mysql
6.
tar -xvf mysql-5.5.32.tar.gz
Cd mysql-5.5.32
执行
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
执行完毕后,会出现
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /u01/software/mysql-5.5.32(这个就是软件解压的位置)
7.
make && make install
8.
[root@cmakemysql mysql-5.5.32]# which cmake
/usr/local/bin/cmake
[root@cmakemysql mysql-5.5.32]# ln -s /application/mysql-5.5.32/ /application/mysql
9.[root@cmakemysql support-files]# pwd
/u01/software/mysql-5.5.32/support-files
[root@cmakemysql support-files]# ls
my-huge.cnf my-small.cnf mysql-multi.server.sh
my-huge.cnf.sh my-small.cnf.sh mysql.server
my-innodb-heavy-4G.cnf mysql.5.5.32.spec mysql.server.sh
my-innodb-heavy-4G.cnf.sh mysqld_multi.server mysql.server-sys5.sh
my-large.cnf mysqld_multi.server.sh mysql.spec
my-large.cnf.sh mysql-log-rotate mysql.spec.sh
my-medium.cnf mysql-log-rotate.sh
my-medium.cnf.sh mysql.m4
配置文件的选择方法:
测试环境选小的,生产环境可以根据硬件选择,例如:my-innodb-heavy-4G.cnf
[root@cmakemysql support-files]# cp my-small.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? Y
10.配置环境变量(故障问题:http://oldboy.blog.51cto.com/2561410/1122867)
[root@cmakemysql support-files]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
You have mail in /var/spool/mail/root
[root@cmakemysql support-files]# tail -l /etc/profile
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
unset i
unset -f pathmunge
export PATH=/application/mysql/bin:$PATH
[root@cmakemysql support-files]# source /etc/profile
[root@cmakemysql support-files]# echo $PATH
/application/mysql/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
11.初始化数据文件
[root@cmakemysql support-files]# ll /application/mysql/d
data/ docs/
[root@cmakemysql support-files]# ll /application/mysql/data/
total 4
drwxr-xr-x. 2 root root 4096 Dec 28 14:24 test
建立mysql数据文件目录
[root@cmakemysql support-files]#mkdir -p /application/mysql/data/
授权mysql用户访问mysql的安装目录
[root@cmakemysql support-files]# chown -R mysql.mysql /application/mysql/data/
调整/tmp权限,否则初始化会失败
[root@cmakemysql mysql]# chmod -R 1777 /tmp
12.安装mysql数据库文件,注意命令路径
[root@cmakemysql mysql]# cd /application/mysql/scripts/
[root@cmakemysql scripts]# ls
mysql_install_db
[root@cmakemysql scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h cmakemysql password 'new-password'
Alternatively you can run:
/application/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems with the /application/mysql//scripts/mysqlbug script!
[root@cmakemysql support-files]# pwd
/u01/software/mysql-5.5.32/support-files
[root@cmakemysql support-files]# cp mysql.server /etc/init.d/mysqld
[root@cmakemysql support-files]# chmod +x /etc/init.d/mysqld
[root@cmakemysql support-files]# /etc/init.d/mysqld start
Starting MySQL... [ OK ]
12.删除无关的用户和数据库
[root@cmakemysql support-files]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user,host from mysql.user;
+------+------------+
| user | host |
+------+------------+
| root | 127.0.0.1 |
| root | ::1 |
| | cmakemysql |
| root | cmakemysql |
| | localhost |
| root | localhost |
+------+------------+
6 rows in set (0.00 sec)
mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)
mysql> delete from mysql.user where host='::1';
Query OK, 1 row affected (0.00 sec)
mysql> delete from mysql.user where host='cmakemysql';
Query OK, 1 row affected (0.01 sec)
也可以直接
mysql> delete from mysql.user where host!=‘localhost’or host!=‘127.0.0.1'
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
或者干脆全部删除,添加额外的管理员
mysql> delete from mysql.user;
Query OK, 2 rows affected (0.01 sec)
mysql> select user,host from mysql.user;
Empty set (0.00 sec)
mysql> grant all privileges on *.* to system@'localhost' identified by 'System123!@#' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| system | localhost |
+--------+-----------+
1 row in set (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> drop database test;
Query OK, 0 rows affected (0.03 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)