修改文件句柄
vim /etc/security/limits.conf
# 修改
* soft nofile 65535
* hard nofile 65535
添加用户
useradd -s /usr/sbin/nologin mysql
mkdir -p /home/mysqldata
chown -R mysql:mysql /home/mysqldata
下载解压授权
wget http://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz
tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz -C /opt/
cd /opt
ln -sv /opt/mysql-5.5.49-linux2.6-x86_64 /opt/mysql
chown -R mysql:mysql /opt/mysql /opt/mysql-5.5.49-linux2.6-x86_64
my.cnf配置文件
cat >> /etc/my.cnf << EOF
# --------------------------- Start -----------------------
#my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysql]
prompt="\\u@\\h \\D \\R:\\m:\\s [\\d]\n-->
#pager="less -i -n -S"
tee=/home/mysqldata/query.log
[mysqld]
user = mysql
basedir = /opt/mysql
datadir = /home/mysqldata
port = 3306
socket = /tmp/mysql.sock
#timeout
interactive_timeout = 300
wait_timeout = 300
#character set
character-set-server = utf8
open_files_limit = 65535
max_connections = 1000
max_connect_errors = 100000
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = /home/mysqldata/slow.log
log-error = /home/mysqldata/error.log
log_warnings = 2
pid-file = /home/mysqldata/mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1
# binlog
binlog_format = mixed
server-id = 1
log-bin = mybinlog
binlog_cache_size = 4M
max_binlog_size = 512M
innodb_log_files_in_group = 2
max_binlog_cache_size = 512M
sync_binlog = 1
expire_logs_days = 10
skip_name_resolve = 1
# buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
# myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 1
# innodb
# 注意按情况修改 buffer pool大小
innodb_buffer_pool_size = 1G
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 64M
innodb_log_file_size = 256M
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
# --------------------------- End -----------------------
EOF
初始化
/opt/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/home/mysqldata --defaults-file=/etc/my.cnf
启动文件
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql
# 修改 46 47 行
basedir=/opt/mysql
datadir=/home/mysqldata
环境变量配置
chown -R mysql:mysql /home/mysqldata
/opt/mysql
vim /etc/profile.d/mysql.sh
export PATH=/opt/mysql/bin:$PATH
cat >> /etc/ld.so.conf.d/mysql.conf <<EOF
/opt/mysql/lib
EOF
xxxxxxxxxx
3
1
cat >> /etc/ld.so.conf.d/mysql.conf <<EOF
2
/opt/mysql/lib
3
EOF
启动文件
/etc/init.d/mysql start # 启动数据库
/etc/init.d/mysql stop # 停止数据库
1
/etc/init.d/mysql start # 启动数据库
2
/etc/init.d/mysql stop # 停止数据库
自动启动
checkconfig add server.service
checkconfig mysql.server on
x
1
checkconfig add server.service
2
checkconfig mysql.server on