源码安装mysql5.6.38测试及教程-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

源码安装mysql5.6.38测试及教程

下文给大家带来源码安装MySQL5.6.38测试及教程,希望能够给大家在实际运用中带来一定的帮助,MYSQL涉及的东西比较多,理论也不多,网上有很多书籍,今天我们就用创新互联在行业内累计的经验来做一个解答。

公司主营业务:成都网站建设、做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出南昌免费做网站回馈大家。

1、环境centos7 x64
CentOS Linux release 7.4.1708 (Core) 关闭selinux
下载 https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.38.tar.gz
yum install gcc gcc-c++ ncurses-devel cmake  libaio bison perl-Module-Install.noarch -y
2、权限
建立用户
#useradd -r -g mysql -s /sbin/nologin -M mysql
数据库存放目录设置成mysql用户mysql组
mkdir -p /data/mysqldata/3306用来存放数据库并赋予权限
chown -R mysql.mysql /data/mysqldata/3306
3、编译mysql5.6.38.tar.gz,解压 tar zxvf mysql5.6.38.tar.gz
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql3306 -DMYSQL_DATADIR=/data/mysqldata/3306 -DSYSCONFDIR=/usr/local/mysql3306/etc -DMYSQL_UNIX_ADDR=/usr/local/mysql3306/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
然后执行
make && make install

源码安装mysql5.6.38测试及教程

4、编译完成配置mysql服务权限
# cd /usr/local/mysql3306
# chown -R mysql:mysql .
# mkdir -p /data/mysql
# mkdir -p /usr/local/mysql3306/etc
# chown mysql.mysql -R /data
# chmod 775 -R /data

scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql3306 --datadir=/data/mysqldata/3306/
和配置my.cnf 保持一致
#### chown -R root:mysql . (将权限设置给root用户,并设置给mysql组, 取消其他用户的读写执行权限,仅留给mysql "rx"读执行权限,其他用户无任何权限)
## chown -R mysql:mysql ./data (数据库存放目录设置成mysql用户mysql组)
## chmod -R ug+rwx . (赋予读写执行权限,其他用户权限一律删除仅给mysql用户权限)

# cp support-files/my-default.cnf /usr/local/mysql3306/etc/my.cnf (可以放在/etc/my.cnf)
修改my.cnf配置,先使用简单配置,测试数据库正常后,再增加优化配置
# vi /etc/my.cnf
#[mysqld] 下面添加:
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql3306
datadir=/data/mysqldata/3306
port=3306
socket=/data/mysqldata/3306/mysql.sock
server_id=1
[mysqld_safe]
log-error=/data/mysqldata/3306/log/mysqld.log
备注修改 datadir=/data/mysqldata/3306 需要在 scripts/mysql_install_db --user=mysql 添加 --datadir=/data/mysqldata/3306
5、 启动mysql
# bin/mysqld_safe --user=mysql &
看是否成功
# ps –ef|grep mysql**

将mysql的启动服务添加到系统服务中
# cp support-files/mysql.server /etc/init.d/mysql3306
现在可以使用下面的命令启动mysql
# service mysql3306 start
停止mysql服务
# service mysql3306 stop
重启mysql服务
# service mysql3306 restart

6、修改root用户密码
# cd /usr/local/mysql3306
# ./bin/mysqladmin -u rootpassword
New password:
Confirm new password:
回车在接下来的提示中设置新密码即可。。
# service mysql3306 restart; (重启mysql云服务器)

7、登录mysql测试
#cd
#vim .bash_profile
修改.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql3306/bin
然后source .bash_profile
#mysql -uroot -p
mysql> use mysql;
mysql> select host,user from mysql.user;

8、我这生产环境下my.cnf配置
#
##mysql configure file my.cnf
#
[client]
port    = 3306
socket  = /usr/local/mysql3306/mysql.sock

[mysql]
prompt="\u@mysqldb \R:\m:\s [\d]> "
no-auto-rehash

[mysqld]
user    = mysql
port    = 3306
basedir = /usr/local/mysql3306
datadir = /data/mysqldata/3306
socket  = /usr/local/mysql3306/mysql.sock
pid-file = /data/mysqldata/datasql-2.pid
character-set-server = utf8
lower_case_table_names=1
skip_name_resolve = 1
open_files_limit    = 65535
back_log = 1024
max_connections = 2000
max_connect_errors = 1000000
table_definition_cache = 1024
table_open_cache_instances = 64
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size = 3000
query_cache_size = 0
query_cache_type = 0
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
slow_query_log_file = /data/mysqldata/3306/log/slow.log
log-error = /data/mysqldata/3306/log/mysqld.log
long_query_time = 0.1
log_queries_not_using_indexes =1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1
server-id = 43   #主从复制加上次参数,数值可以按IP末尾数,也可以其他值
log-bin = mysql-bin  #主从复制加上次参数
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
expire_logs_days = 7
master_info_repository = TABLE
relay_log_info_repository = TABLE
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
lock_wait_timeout = 3600
explicit_defaults_for_timestamp = 1
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30

log_bin_trust_function_creators = 1
transaction_isolation = REPEATABLE-READ

innodb_buffer_pool_size = 91750M   #参考服务器内存情况,按内存的80%填写
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1

innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
innodb_log_file_size = 2G
innodb_log_files_in_group = 2

# 根据您的服务器IOPS能力适当调整
# 普通SSD盘的话,可以调整到 10000 - 20000
#高端PCIe SSD卡的话,调整的更高,比如 50000 - 80000
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4

innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_checksum_algorithm = crc32

innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 4G

innodb_stats_on_metadata = 0

innodb_status_file = 1
# 开启 innodb_status_output & innodb_status_output_locks , 可能会导致log-error文件增长较快
innodb_status_output = 0
innodb_status_output_locks = 0

#performance_schema
performance_schema = 1
performance_schema_instrument = '%=on'

#innodb monitor
innodb_monitor_enable="module_innodb"
innodb_monitor_enable="module_server"
innodb_monitor_enable="module_dml"
innodb_monitor_enable="module_ddl"
innodb_monitor_enable="module_trx"
innodb_monitor_enable="module_os"
innodb_monitor_enable="module_purge"
innodb_monitor_enable="module_log"
innodb_monitor_enable="module_lock"
innodb_monitor_enable="module_buffer"
innodb_monitor_enable="module_index"
innodb_monitor_enable="module_ibuf_system"
innodb_monitor_enable="module_buffer_page"
innodb_monitor_enable="module_adaptive_hash"

[mysqldump]
quick
max_allowed_packet = 32M
[mysqld_safe]
log-error = /data/mysqldata/3306/log/mysqld.log
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

看了以上关于源码安装mysql5.6.38测试及教程,如果大家还有什么地方需要了解的可以在创新互联行业资讯里查找自己感兴趣的或者找我们的专业技术工程师解答的,创新互联技术工程师在行业内拥有十几年的经验了。

 

 


文章名称:源码安装mysql5.6.38测试及教程
分享URL:http://kswsj.cn/article/gsohsi.html

其他资讯