Mysql源码编译安装
2016-10-12 15:56
344 查看
安装环境说明:
操作系统:centos 7Mysql 源码版本:mysql-5.7.9
安装步骤:
1.安装依赖包yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
2.下载源码包
cd /usr/local/source wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.9.tar.gz[/code]
附:百度云盘分享 http://pan.baidu.com/s/1qYo2luW
添加用户组groupadd mysql useradd -r -g mysql mysql
4.编译&安装tar xzf boost_1_59_0.tar.gz tar xzf mysql-5.7.9.tar.gz mkdir -p /data/mysql cd mysql-5.7.9 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=../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=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 make make install
5.启动脚本,设置开机自启动cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on
6.配置mysql的/etc/my.cnf
仅供参考,实际可根据生产环境调整[client] port = 3306 socket = /tmp/mysql.sock default-character-set = utf8mb4 [mysqld] port = 3306 socket = /tmp/mysql.sock basedir = /usr/local/mysql datadir = /data/mysql pid-file = /data/mysql/mysql.pid user = mysql bind-address = 0.0.0.0 server-id = 1 init-connect = 'SET NAMES utf8mb4' character-set-server = utf8mb4 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 = 4M 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 = /data/mysql/mysql-error.log slow_query_log = 1 long_query_time = 1 slow_query_log_file = /data/mysql/mysql-slow.log performance_schema = 0 explicit_defaults_for_timestamp lower_case_table_names = 1 skip-external-locking default_storage_engine = InnoDB innodb_file_per_table = 1 innodb_open_files = 500 innodb_buffer_pool_size = 64M 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 = 10G 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
7.初始化数据库/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local 9dd9 /mysql --datadir=/data/mysql
8.启动数据库service mysqld start
9.设置root密码/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"password\" with grant option;" /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"password\" with grant option;"
10.开放防火墙端口firewall-cmd --zone=public --add-port=80/tcp --permanent #开放指定端口 firewall-cmd --zone=public --add-port=3306/tcp --permanent systemctl stop firewalld.service #重启防火墙 systemctl start firewalld.service
其他相关操作:
如何设置远程登录MySQL?grant all on yourdb.* to yourUsername@yourHost identified by "yourPassword" with grant option; flush privileges;
如何修改root密码?use mysql; update user set authentication_string=password('新密码') where user='root'; flush privileges;
相关文章推荐
- Red Hat Linux 9下的Mysql5.0.19+Apache 2.2.0 + PHP 5.1.2+GD库源码编译安装过程
- ubuntu 10.10 源码编译安装mysql 5.1
- Ubuntu编译安装mysql源码
- CENTOS6下MYSQL5.519源码编译安装
- Redhat AS 5 源码编译安装 mysql-5.1.49
- ubuntu10.10,下载mysql源码,编译安装
- Linux 下 MySQL 5.5.8 源码编译安装记录
- Linux 下 MySQL 5.5.8 源码编译安装记录
- ubuntu 10.10 源码编译安装mysql 5.5
- CentOS5.6下使用cmake编译MySQL5.5.13源码和安装笔录
- CentOS5.6下使用cmake编译MySQL5.5.13源码和安装笔录 推荐
- Linux 下 MySQL 5.5.8 源码编译安装记录
- CentOS 4.4下源码编译安装apache+php+mysql
- CentOS5.6下使用cmake编译MySQL5.5.13源码和安装笔录
- mysql源码编译安装以及初始设置
- CentOS5.6下使用cmake编译MySQL5.5.13源码和安装笔录
- 在ubuntu中用源码编译方式安装好了mysql和php
- Linux下源码编译MySQL 5.5 与安装过程全记录
- 源码编译安装 MySQL 5.5.13 实践