mysql5.7安装步骤(⼆进制⽂件安装)
之前在linux环境下⽤源码编译安装了mysql5.7.12的版本,后来还需要安装mysql5.7的版本,就想着⽤⼆进制⽂件的⽅式安装,毕竟⼆进制⽂件的安装⽅式⽅便简单,基本的配置都能实现,详细过程如下:
1.下载安装包
提取码:kma7
2.创建⽤户
#创建mysql⽤户(此⽤户不需要登录权限)
groupadd mysql
useradd -s /sbin/nologin -g mysql mysql
3.安装
mkdir /app
tar -xf mysql-5.7.26-linux-glibc2.12-x86_ -C /app/getui_mysql
ln -s /app/getui_mysql/mysql-5.7.26-linux-glibc2.12-x86_64 /app/getui_mysql/mysql
#设置环境变量
echo 'export PATH=/app/getui_mysql/mysql/bin:$PATH' >> /etc/profile
source /etc/profile
#查看mysql的版本信息
mysql -V
4.配置myf⽂件
配置完之后可以在msyql⽇初始化时直接⽤myf⽂件进⾏⽇初始化⽐较⽅便
下⾯这个是我⾃⼰的myf⽐较全⾯,可以参看,详细的解释请参考另⼀篇博客:
[client]
port = 3306
socket = /app/getui_mysql/mysql/mysql.sock
[mysql]
prompt="\\u@\\h [\\d]>"
no-auto-rehash
[mysqld]
basedir = /app/getui_mysql/mysql
datadir = /data/mysql/data
socket = /app/getui_mysql/mysql/mysql.sock
tmpdir = /app/getui_mysql/mysql/tmp
user = mysql
port = 3306
server-id = 2
mysql下载后安装中出现提示不到安装包character-set-server = utf8mb4
event_scheduler = 0
sql_mode=''
default-time-zone = SYSTEM
log_timestamps = SYSTEM
explicit_defaults_for_timestamp=true
explicit_defaults_for_timestamp=true
group_concat_max_len=102400
interactive_timeout = 600
wait_timeout = 600
open_files_limit = 65535
max_connections = 10000
max_connect_errors = 1000000
lower_case_table_names =1
skip_name_resolve = 1
gtid-mode = on
enforce-gtid-consistency=1
lock_wait_timeout = 3600
log-output=file
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /app/getui_mysql/mysql/logs/slow.log log-slow-slave-statements = 1
log_slow_admin_statements = 1
log_queries_not_using_indexes =1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log-error = /app/getui_mysql/mysql/logs/error.log
log_error_verbosity = 2
binlog_format = row
log-bin = /app/getui_mysql/mysql/logs/mysql-bin
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
sync_binlog = 0
log_bin_trust_function_creators=1
expire_logs_days = 10
secure_file_priv="/tmp"
skip_slave_start = 1
max_relay_log_size = 128M
relay_log_purge = 1
relay_log_recovery = 1
relay-log=/app/getui_mysql/mysql/logs/relay-bin
relay-log-index=/app/getui_mysql/mysql/logs/relay-bin.index log_slave_updates
relay-log-purge = 1
query_cache_size = 0
query_cache_type = 0
table_open_cache = 1024
table_definition_cache = 1024
table_open_cache_instances = 64
max_heap_table_size = 96M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 200
thread_cache_size = 200
thread_stack = 512K
tmp_table_size = 96M
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
thread_cache_size = 7518
back_log = 1024
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 5G
myisam_repair_threads = 1
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 8
innodb_buffer_pool_dump_at_shutdown = 1 innodb_buffer_pool_load_at_startup = 1
innodb_data_file_path = ibdata1:1G:autoextend innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 8M
innodb_log_file_size = 1G
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
transaction_isolation = REPEATABLE-READ innodb_flush_method = O_DIRECT
innodb_stats_on_metadata = 0
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
internal_tmp_disk_storage_engine = InnoDB
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
performance_schema = 1
performance_schema_instrument = '%=on'
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_flush_neighbors = 1
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" inno
db_monitor_enable="module_adaptive_hash"
[mysqldump]
[mysqldump]
quick
max_allowed_packet = 32M
5.初始化数据库
mkdir /app/mysql/logs/ -p
mkdir /app/mysql/tmp -p
mkdir /data/mysql/data -p
chown -R mysql:mysql /data
chown -R mysql:mysql /app/getui_mysql
/
app/getui_mysql/mysql/bin/mysqld --defaults-file=/etc/myf --initialize
初始化没有信息输出,最后直接完成即可,该初始化之后会分配⼀个临时使⽤的密码保存在/app/mysql/logs/error.log⾥⾯
#/app/getui_mysql/mysql/bin/mysqld --initialize-insecure --datadir=/data/mysql/data/ --user=mysql --
basedir=/app/getui_mysql/mysql/
该命令也可以初始化,不⽤使⽤myf⽂件,且没有初始化是产⽣临时使⽤的密码
6.启动/关闭mysql
前台启动命令:
/app/getui_mysql/mysql/bin/mysqld --defaults-file=/etc/myf --user=mysql &
/app/getui_mysql/mysql/bin/mysqladmin -S /app/getui_mysqlmysql/mysql.sock -p'' shutdown
-p''后⾯是密码
关闭:
直接kill 也可,⽤下⾯的命令也可以
/app/getui_mysql/mysql/bin/mysqladmin -S /app/getui_mysql/mysql/mysql.sock -p'' shutdown
-p''后⾯是密码
7.进⼊mysql并修改密码
初始化时系统给的密码是临时性的,进⼊mysql后需要修改密码
mysql -u root -p
输⼊系统产⽣的密码
执⾏下⾯的密令就⾏密码修改:
set password='123456';
delete from mysql.user where user<>'root' or host<>'localhost';
flush privileges;
⾄此mysql就可以正常使⽤了
8.配置service mysqld start 命令
有没有发现没有使⽤service mysqld start 命令来启动mysql数据库,这个命令是需要进⾏配置之后才能使⽤的,配置⽅法如下:
cp /app/getui_mysql/mysql/support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld #修改下⾯两⾏
basedir=/app/getui_mysql/mysql
datadir=/data/mysql/data
ln -s /etc/myf /app/mysql/myf
然后就可以使⽤service mysqld start/stop restart 命令来操作数据库了
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论