数据库安装
1新增mysql用户
[root@HE1mysql]# groupadd mysql -g 502 [root@HE1mysql]# useradd -g mysql -s /sbin/nologin -d /home/mysql mysql
系统环境配置:
[root@HE1mysql]# yum install -y gcc gcc-c++ make ncurses-devel bison cmake libaiolibaio-devel
2编译安装
[root@HE1mysql]# mkdir -p /data/mysql [root@HE1mysql]# mkdir -p /log/mysql [root@HE1mysql]# chown -R mysql:mysql /data/mysql [root@HE1mysql]# tar xvf mysql-5.5.31.tar.gz [root@HE1mysql]# cd mysql-5.5.31 [root@HE1 mysql-5.5.31]# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 [root@HE1mysql-5.5.31]# make [root@HE1mysql-5.5.31]# make install
3创建MySQL授权表
[root@HE1 mysql]# cd/usr/local/mysql [root@HE1 mysql]#chown -R mysql:mysql . [root@HE1mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql [root@HE1mysql]# cp support-files/my-medium.cnf /etc/my.cnf
4配置mysql
[root@HE1mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@HE1mysql]# chmod 700 /etc/init.d/mysqld [root@HE1 init.d]# chkconfig --add mysqld [root@HE1mysql]# chkconfig --level 2345 mysqld on [root@HE1 local]# echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib">>/etc/profile [root@HE1~]# source /etc/profile
5修改配置文件(my.cnf )
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
skip-external-locking
key_buffer_size =16M
max_allowed_packet =1M
table_open_cache =64
sort_buffer_size =512K
net_buffer_length =8K
read_buffer_size =256K
read_rnd_buffer_size= 512K
myisam_sort_buffer_size= 8M
max_connections=500
log-error=/log/mysql/mysql
datadir=/data/mysql
6启动mysql服务器
[root@HE1mysql]# /etc/init.d/mysqld start
7修改mysql中root用户的密码
[root@HE1bin]# ./mysqladmin -uroot password 'MANAGER'