美文网首页
MySQL 5.7手动安装步骤

MySQL 5.7手动安装步骤

作者: 粤海门明哥 | 来源:发表于2020-04-15 15:56 被阅读0次

MySQL 5.7手动安装步骤

一,下载

1.1 下载地址

https://dev.mysql.com/downloads/mysql/

download :https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz

1.2 mysql主配置信息

内存:2-4G

二,安装配置

2.1 解压安装文件到/usr/local/

cd /usr/local/

tar xf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz -C /usr/local

mkdir /usr/local/mysql

unlink /usr/local/mysql

ln -fs /usr/local/mysql-5.7.29-linux-glibc2.12-x86_64 /usr/local/mysql

2.2 创建数据目录&mysql用户

mkdir -p /data/mysql/3306/{data,binlog,relaylog,dblog,tmp}

touch /data/mysql/3306/dblog/error.log

useradd mysql

chown -R mysql.mysql /data/mysql/3306

2.3 创建配置文件到

vim /data/mysql/3306/my.cnf

[client]

port = 3306

socket = /data/mysql/3306/mysql.sock

[mysql]

no-auto-rehash

#prompt = "\\u@\\d \\R:\\m> "

prompt = "\\u@\\h : \\d \\R:\\m:\\s> "

character-set-server = utf8mb4

# The MySQL server

#########Basic##################

[mysqld]

server-id = 883306

port = 3306

user = mysql

basedir = /usr/local/mysql

datadir = /data/mysql/3306/data

socket = /data/mysql/3306/mysql.sock

pid-file = /data/mysql/3306/mysql.pid

skip-external-locking

skip-name-resolve

default-storage-engine = InnoDB

character-set-client-handshake = FALSE 

character-set-server = utf8mb4

init_connect='set names utf8mb4'

#wait_timeout = 200

#interactive_timeout = 200

connect_timeout = 20

back_log = 1000

log_bin_trust_function_creators = 1

lower_case_table_names = 1

#read_only = 1

sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

secure_file_priv = '/data/mysql/3306/tmp'

transaction_isolation = READ-COMMITTED

#######: for per_thread_buffers ############

max_connections = 1000

#max_user_connections = 1000

max_connect_errors = 10000000

key_buffer_size = 16M

max_allowed_packet = 128M

thread_cache_size = 320

thread_stack = 256K

table_open_cache = 6144

table_definition_cache = 4096

table_open_cache_instances = 64

sort_buffer_size = 512K

read_buffer_size = 512K

read_rnd_buffer_size = 512k

join_buffer_size = 512K

tmp_table_size = 64M

max_heap_table_size = 128M

query_cache_type = 0

query_cache_size = 0

bulk_insert_buffer_size = 32M

#max_prepared_stmt_count = 1048576

######### : for binlog ##################

log-bin = /data/mysql/3306/binlog/mysql-bin

binlog_format = row

binlog_rows_query_log_events = on

log_slave_updates = 1

max_binlog_size = 512M

binlog_cache_size = 65535

expire-logs-days = 7

sync_binlog = 1

slave-preserve-commit-order = ON

relay-log = /data/mysql/3306/relaylog/mysql-relay

#########: for replication #############

slave-net-timeout = 20

skip-slave-start

sync_master_info = 1

sync_relay_log_info = 1

relay_log_recovery = 1

#slave-parallel-type=LOGICAL_CLOCK

#slave-parallel-workers=16

master_info_repository=TABLE

relay_log_info_repository=TABLE

#########: for slow log #############

slow_query_log = 1

slow_query_log_file = /data/mysql/3306/dblog/mysql.slow

log_queries_not_using_indexes = on

long_query_time = 2

#########: for error log #############

log-error = /data/mysql/3306/dblog/error.log

general_log = off

#########: for gtid#############

#gtid_executed_compression_period = 1000

#gtid_mode = on

#enforce_gtid_consistency = on

#########: for InnoDB #############

#5.7.29 废弃了

#default_stroage_engine = innodb

#default_tmp_stroage_engine = innodb

innodb_data_home_dir = /data/mysql/3306/data

innodb_data_file_path = ibdata1:128M:autoextend

innodb_temp_data_file_path = ibtmp1:1024M:autoextend:max:5G

innodb_buffer_pool_size = 1G

innodb_log_file_size = 200M

innodb_log_buffer_size = 128M

innodb_log_files_in_group = 2

innodb_thread_concurrency = 0

innodb_max_dirty_pages_pct = 85

innodb_support_xa = 0

innodb_flush_log_at_trx_commit = 0

innodb_flush_method = O_DIRECT

innodb_read_io_threads = 8

innodb_write_io_threads = 8

innodb_io_capacity = 200

innodb_io_capacity_max = 2000

#----ssd

#innodb_io_capacity = 2000

#innodb_flush_neighbors = 0

#innodb_page_size = 8K

#innodb_log_block_size = 4096

innodb_file_per_table = 1

innodb_file_format = Barracuda

innodb_file_format_max = Barracuda

innodb_strict_mode = 1

innodb_purge_threads = 4

innodb_page_cleaners=4

innodb_purge_batch_size = 32

innodb_print_all_deadlocks = on

innodb_deadlock_detect = on

innodb_lock_wait_timeout = 50

innodb_spin_wait_delay = 6

innodb_autoinc_lock_mode = 2

innodb_stats_on_metadata = off

innodb_checksum_algorithm=crc32

innodb_open_files = 65535

#metadata_locks_hash_instances=32

innodb_online_alter_log_max_size = 128M

#-----Persistent Optimizer Statistics

innodb_stats_auto_recalc = on

innodb_stats_persistent = on

innodb_stats_persistent_sample_pages = 20

innodb_adaptive_hash_index = on

innodb_change_buffering = all

innodb_change_buffer_max_size = 25

innodb_flush_log_at_timeout = 1

innodb_flush_log_at_trx_commit = 1

#-----innodb scan resistant

innodb_old_blocks_pct = 37

innodb_old_blocks_time = 1000

#----innodb read ahead

innodb_read_ahead_threshold = 56

innodb_random_read_ahead = off

#-----innodb buffer pool state(5.7)

innodb_buffer_pool_dump_pct = 40

innodb_buffer_pool_dump_at_shutdown = ON

innodb_buffer_pool_load_at_startup = ON

innodb_undo_log_truncate = 1

innodb_max_undo_log_size = 2G

innodb_purge_rseg_truncate_frequency = 128

binlog_gtid_simple_recovery=1

binlog_error_action=ABORT_SERVER

log_timestamps=system

transaction_write_set_extraction=MURMUR32

show_compatibility_56=on

internal_tmp_disk_storage_engine=INNODB

eq_range_index_dive_limit=200

[mysqldump]

quick

max_allowed_packet = 512M

[mysqld_safe]

numa_interleave = 1

open-files-limit = 65535

2.4 初使化

/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/3306/my.cnf --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data/

2.5 启动服务

/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/3306/my.cnf --user=mysql &

2.6 初始化密码

这种安装是无密码本机登录

/usr/local/mysql/bin/mysql -uroot -S /data/mysql/3306/mysql.sock

ln -fs /data/mysql/3306/mysql.sock /tmp

就不用每次 -S /data/mysql/3306/mysql.sock

其他安装方式需要输入密码

/usr/local/mysql/bin/mysql -uroot -p

2.7 MySQL5.7 root开放远程连接

例如,你想使用账号username 使用密码 password 从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'root '@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

FLUSH  PRIVILEGES;

别忘了执行语句 FLUSH RIVILEGES 使修改生效

相关文章

  • MySQL 5.7手动安装步骤

    MySQL 5.7手动安装步骤 一,下载 1.1 下载地址 https://dev.mysql.com/downl...

  • MySQL 5.7 安装步骤

    MySQL 5.7 安装步骤 MySQL 5.7 安装包: 链接:https://pan.baidu.com/s/...

  • docker安装mysql8.0

    指定mysql密码 自动生成密码.也可以手动指定 安装 mysql 安装8.0 安装5.7(没测试,应该问题不大)...

  • CentOS7 安装 MySQL 5.7

    由于某些历史原因,yum默认不提供 MySQL 5.7 安装源,所以需要手动添加。 一、手动添加 MySQL yu...

  • docker安装mysql8.0

    mysql5.7 安装在最后 指定mysql密码 自动生成密码.也可以手动指定 安装 mysql8.0 ​查看My...

  • Ubuntu - 安装、卸载 MySQL 5.7

    Ubuntu 17.10 安装 MySQL 5.7 安装步骤$ sudo apt-get update$ sudo...

  • Python 3 与 MySQL 5.7

    1.环境: mysql 5.7 安装步骤windows10python3.5PyMySQL(用来连接mysql数...

  • Mac/linux 下安装mysql 社区版

    下面主要是mysql5.7.x 在Mac上的安装经验 安装步骤如下 下载安装包https://dev.mysql....

  • CentOS 7 安装 mysql 5.7

    下载mysql5.7源安装包 安装mysql5.7源 安装mysql5.7 启动mysql,并将其加入到自启动。 ...

  • pymysql的用法

    一、首先要安装MySQL,我安装的mysq5.7的;具体安装步骤可以自行百度,或者参考这个win10安装MYSQL...

网友评论

      本文标题:MySQL 5.7手动安装步骤

      本文链接:https://www.haomeiwen.com/subject/ylwcvhtx.html