mysql -- mysql5.7.9 安装文档

0. 包的存放路径/usr/local/
mysql的目录/usr/local/mysql/data
/usr/local/mysql/logs
/usr/local/mysql/init.d/
/usr/local/mysql/etc
/usr/local/mysql/tmp


mkdir -pv /usr/local/mysql/data /usr/local/mysq/tmp

1.安装依赖包
yum -y install gcc* gcc-c++* bzip* python-devel* ncurses ncurses-devel* bison make \
autoconf automake zlib libgcrypt libtool bzip2 patch psmisc screen curl

 

2.创建mysql用户
useradd -M -s /sbin/nologin mysql


3.安装boots
下载boots包,并解压
tar -jxvf boost_1_59_0.tar.gz
cd boost_1_59_0
./bootstrap.sh
./bz2
./bz2 install


4.安装cmake
下载cmake包解压
tar xf cmake-2.8.2.tar.gz

cd /usr/local/cmake-2.8.2/
./bootstrap
gmake
gmake install


5.安装MySQL

tar xzf mysql-5.7.9.tar.gz
cd mysql-5.7.9
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost_1_59_0 \
-DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EMBEDDED_SERVER=1

编译安装

make -j `grep processor /proc/cpuinfo | wc -l` #编译很消耗系统资源,小内存可能编译通不过
make install


cat > /etc/my.cnf << EOF
[client]
port = 3306
socket = /tmp/mysql.sock
#default-character-set = utf8
[mysqld]
port = 3306
socket = /tmp/mysql.sock

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 10

character-set-server = utf8
skip-name-resolve
#skip-networking
back_log = 300

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 32M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30

log_error = /usr/local/mysql/data/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /usr/local/mysql/data/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 2048M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
EOF

初始化数据库
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chown -R mysql.mysql /usr/local/mysql 更改目录所有者

service mysqld start 启动服务

vim /root/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin/


mysqladmin -u root -p password    #设置登录密码,没有默认登陆密码,第一步直接回车

mysql -u root -p           #登陆数据库

chkconfig mysqld on   #设置MySQL开机启动

posted @ 2017-12-04 11:30  求其在我  阅读(753)  评论(0编辑  收藏  举报