linux 下mysql的安装文档
mkdir -p /opt/modules/ /opt/modules/src
添加数据库用户
adduser mysql
下载源码包到/opt/modules/
cd /opt/modules/
解压
tar -zxvf mysql-4.0.25.tar.gz -C src/
进入源码目录进行配置
cd /opt/distfiles/src/mysql-4.0.25/
使用优化编译:
export CFLAGS="-O6 -mpentium -fomit-frame-pointer"(过期了,用下面取代)
export CFLAGS="-O6 -march=pentium -fomit-frame-pointer"
export CXX=gcc
export CXXFLAGS="-O6 -march=pentium -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
./configure --prefix=/opt/modules/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --without-debug --with-mysqld-user=mysql --with-big-tables
编译和安装
make
make install
拷贝配置文件
cp support-files/my-huge.cnf /etc/my.cnf
修改/etc/my.cnf 文件,修改或增加如下内容:
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer = 384M
max_allowed_packet = 3M
read_buffer_size = 20M
myisam_sort_buffer_size = 128M
query_cache_size = 64M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
set-variable=back_log=1024
set-variable=interactive_timeout=7200
set-variable=wait_timeout=7200
set-variable=key_buffer_size=16773120
set-variable=max_connections=2048
set-variable=record_buffer=16773120
set-variable=sort_buffer=16773120
set-variable=table_cache=512
set-variable=thread_cache_size=80
set-variable=max_connect_errors=2048
set-variable=log_slow_queries=ON
set-variable=delay_key_write=ON
set-variable=join_buffer_size=16773120
log=/var/log/mysqld.log
安装初始化数据库
cd /opt/modules/mysql/
./bin/mysql_install_db --user=mysql
设置属性
chgrp -R mysql var
拷贝启动脚本到/opt/sbin
cp /opt/modules/mysql/share/mysql/mysql.server /opt/sbin/mysql.server
创建mysql日志,并且修改文件属性
touch /var/log/mysqld.log
chown mysql:mysql /var/log/mysqld.log
以后运行,只需要执行如下脚本:
/opt/sbin/mysql.server start|restart|stop
安全及优化配置
删除test库,删除db表里的数据,删除除了host=localhost,user=root 以外的账户
修改root账户密码