1.MySQL5.7安装注意事项

1.在MySQL5.7中mysql_install_db已经不再推荐使用,建议改成mysqld-initialize 完成实力初始化。(mysql_install_db在/mysql/bin目录下,同时取消了/mysql/scripts目录)

2.在初始化是如果加上--initial-insecure,则会创建空密码的root@localhost 账号,否则会创建带密码的root@localhost账号,密码直接写在log-error日志文件中

3.MySQL5.7的安装过程与5.6的主要区别在于数据初始化过程。

5.7.12二进制安装包下载地址:

链接:https://pan.baidu.com/s/1PAeHOyRRSMzRqCUIasE0xQ

密码:12r6

2.MySQL5.7安装

2.1 安装相关依赖包

大部分情况下生产环境在系统初始化的过程中已经安装大部分依赖包,防止偶然时间。

yum -y groupinstall "Development tools"
yum -y install ncurses-devel openssl-devel bison gcc gcc-c++ make

2.2 解压MySQL二进制tar包

cd到mysql二进制的目录,然后使用tar命令解压

tar xf mysql-5.7.-linux-glibc2.-x86_64.tar.gz

2.3 复制相关目录

复制解压后的mysql到mysqlbase目录

 cp -rf mysql-5.7.-linux-glibc2.-x86_64 /usr/local/mysql

2.4 创建MySQL用户

在linux中添加mysql用户

useradd mysql

2.5 创建MySQL数据目录

创建数据目录

mkdir -p /home/mysql3306/mysql3306

创建日志目录

mkdir -p /home/mysql3306/logs

2.6 修改目录权限

修改数据目录、日志目录、base目录权限

chown -R mysql.mysql -R /home/mysql3306
chown -R mysql.mysql -R /usr/local/mysql/

2.7 创建配置文件

删掉系统自带my.cnf,创建自定义配置文件

mv /etc/my.cnf /etc/my.cnf.bak
vim /etc/my3306.cnf

my.cnf配置模板

#mysql5.7.9

[client]
port =
socket = /tmp/mysql3306.sock
default_character_set = utf8mb4 [mysqld]
# *** generic configuration options *** #
lower_case_table_names =
port =
basedir = /usr/local/mysql
datadir = /home/mysql3306/mysql3306
socket = /tmp/mysql3306.sock
pid_file = /home/mysql3306/mysql5711.pid
tmpdir = /tmp/
slave_load_tmpdir = /tmp/ # *** dns resolve *** #
skip_name_resolve =
external_locking
explicit_defaults_for_timestamp = true character_set_client_handshake = FALSE
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci # *** connection *** #
max_connections =
max_connect_errors =
back_log =
interactive_timeout =
wait_timeout = table_definition_cache =
table_open_cache =
#query_cache_size = 64M
#query_cache_limit = 2M
thread_cache_size =
ft_min_word_len =
#performance_schema = OFF ##If large data transfer problems,enlarge max_allowed_packet thread_stack = 192K # *** global memory parameter *** #
max_allowed_packet = 16M
tmp_table_size = 256M
max_tmp_tables =
max_heap_table_size = 96M
#close query cache
#query_cache_type = # *** session memory parameter *** #
sort_buffer_size = 4M
read_buffer_size = 4M #顺序IO
join_buffer_size = 4M
read_rnd_buffer_size = 8M #随机IO
bulk_insert_buffer_size = 64M # # *** engine *** #
default_storage_engine = InnoDB
#ignore_builtin_innodb
#plugin_load=innodb=ha_innodb_plugin.so;innodb_trx=ha_innodb_plugin.so;innodb_locks=ha_innodb_plugin.so;innodb_lock_waits=ha_innodb_plugin.so;innodb_cmp=ha_innodb_plugin.so;innodb_cmp_reset=ha_innodb_plugin.so;innodb_cmpmem=ha_innodb_plugin.so;innodb_cmpmem_reset=ha_innodb_plugin.so # *** log *** #
log_timestamps = system
log_bin = /home/mysql3306/logs/mysql-bin
expire_logs_days =
binlog_format = mixed
#binlog_gtid_simple_recovery =
#binlog_do_db
#binlog_ignore_db
log_slave_updates =
relay_log = /home/mysql3306/logs/mysql5711_relay_bin
relay_log_index = /home/mysql3306/logs/mysql5711_relay_bin.index
relay_log_info_file = /home/mysql3306/logs/mysql5711_relay_bin.info
relay_log_recovery =
log_error = /home/mysql3306/logs/mysql5711.err
slow_query_log =
slow_query_log_file = /home/mysql3306/logs/mysql5711_slow.log
long_query_time =
log_output = FILE
log_queries_not_using_indexes =
log_slow_admin_statements =
log_slow_slave_statements =
log_throttle_queries_not_using_indexes =
min_examined_row_limit =
#general_log = off
general_log_file = /home/mysql3306/logs/mysql5711_general.log
#log_queries_not_using_indexes = /mysqllog/mysql5711/mysql5711_not_useing_index.log max_binlog_cache_size = 8M
max_binlog_size = 1024M
binlog_cache_size = 4M
sync_binlog = server_id =
#read_only =
#slave_skip_errors = all # *** MyISAM Specific options *** #
#key_buffer_size = 128M
#bulk_insert_buffer_size = 64M
#myisam_sort_buffer_size = 128M
#myisam_max_sort_file_size = 10G
#myisam_repair_threads =
#myisam_recover_options = BACKUP,FORCE # *** INNODB Specific options *** #
innodb_data_home_dir = /home/mysql3306/mysql3306/
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_log_group_home_dir = /home/mysql3306/mysql3306/
innodb_buffer_pool_instances =
innodb_buffer_pool_size = 1024MB
innodb_buffer_pool_dump_pct =
innodb_page_cleaners =
innodb_log_file_size = 256M
innodb_log_files_in_group =
innodb_log_buffer_size = 32M #default 16M
innodb_flush_log_at_trx_commit =
innodb_lock_wait_timeout =
innodb_undo_directory = /home/mysql3306/mysql3306/
innodb_undo_logs = #must >=.default
innodb_undo_tablespaces = #must >=
innodb_undo_log_truncate =
innodb_max_undo_log_size = 256M
innodb_purge_rseg_truncate_frequency =
innodb_print_all_deadlocks =
innodb_sort_buffer_size = 64M
#disabled_storage_engines =MyISAM
innodb_buffer_pool_load_at_startup =
innodb_buffer_pool_dump_at_shutdown =
innodb_file_format_max =Antelope
innodb_file_format =Antelope
sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
innodb_open_files =
innodb_file_per_table =
innodb_status_file =
innodb_lock_wait_timeout =
innodb_read_io_threads =
innodb_write_io_threads =
innodb_io_capacity =
innodb_thread_concurrency =
innodb_commit_concurrency =
#innodb_flush_neighbors = #for ssd
#innodb_flush_neighbors = #for other
innodb_purge_batch_size =
innodb_flush_log_at_trx_commit =
innodb_flush_method = O_DIRECT
innodb_purge_threads =
#innodb_file_format = barracuda
innodb_strict_mode =
innodb_support_xa =
skip_innodb_adaptive_hash_index
innodb_force_recovery =
#innodb_fast_shutdown
innodb_change_buffering = all
#innodb_use_native_aio =
innodb_max_dirty_pages_pct = ##replication
#replicate_do_db
#replicate_ignore_db = mysql
#replicate_ignore_db = test
#replicate_do_table
#replicate_ignore_table
#replicate_wild_do_table
#replicate_wild_ignore_table
#gtid_mode = on
#enforce_gtid_consistency = true
master_info_repository = TABLE
relay_log_info_repository = TABLE
sync_master_info =
slave_parallel_workers =
binlog_checksum = CRC32 #default crc32
master_verify_checksum = #default off
slave_sql_verify_checksum =
#binlog_rows_query_log_events = # ##semi sync replication settings
#plugin_dir=/usr/local/mysql57/lib/plugin
#plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
#loose_rpl_semi_sync_master_enabled =
#loose_rpl_semi_sync_slave_enabled =
#loose_rpl_semi_sync_master_timeout = # second ##transaction
transaction_isolation = REPEATABLE-READ
#transaction_write_set_extraction= MURMUR32 #open --single-tra no use [mysqldump]
quick
max_allowed_packet = 16M [mysql]
no_auto_rehash
default_character_set = utf8mb4 [myisamchk]
#key_buffer_size = 20M
#sort_buffer_size = 4M
#read_buffer = 4M
#write_buffer = 2M [mysqlhotcopy]
interactive_timeout [mysqld_safe]
open_files_limit =

2.8 初始化MySQL

MySQL5.7的初始化过程

 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my3306.cnf  --initialize-insecure --explicit_defaults_for_timestamp --basedir=/usr/local/mysql --datadir=/home/mysql3306/mysql3306/ --user=mysql

2.9 启动MySQL

 /usr/local/mysql/bin/mysqld_safe  --defaults-file=/etc/my3306.cnf --datadir=/home/mysql3306/mysql3306/ --user=mysql &

 查看进程和监听端口
ps -ef|grep mysql
netstat -nltp|grep

2.10 进入MySQL

启动后密码为空

/usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock

2.11 安装完成后,简单初始化权限

因为安装完成后,没有详细的权限设置,所以我们需要手动的配置一下简单的权限

 delete from mysql.user where user!='root' or host!='localhost';
update mysql.user set authentication_string=password('root') where user='root';
*需要注意的是,在未来版本,MySQL将废弃此种授权方式
*MySQL5.7 mysql.user表没有password字段改 authentication_string;
grant all privileges on *.* to 'sys_admin'@'%' identified by '123456';
flush privileges; *未来版本的授权方式
CREATE USER sysadmin@localhost IDENTIFIED BY '123456';
grant all privileges on *.* to sysadmin@localhost;

2.12 添加环境变量

echo 'export PATH=$PATH:/usr/local/mysql/bin/' >>/etc/profile
source /etc/profile

本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

MySQL5.7 基于二进制包的安装的更多相关文章

  1. Linux下MySQL5.7.18二进制包安装(无默认配置文件my_default.cnf)

    最新在学习MySQL,纯新手,对Linux了解的也不多,因为是下载的最新版的MySQL(MySQL5.7.18)二进制包,CentOS7.2下测试安装,方便以后折腾.大概步骤如下,安装删除反复折腾了几 ...

  2. Linux下MySQL5.7.18二进制包安装(手动添加配置文件my_default.cnf)

    本文出处:http://www.cnblogs.com/wy123/p/6815049.html 最新在学习MySQL,纯新手,对Linux了解的也不多,因为是下载的最新版的MySQL(MySQL5. ...

  3. mysql5.6的二进制包安装

    author: headsen chen data :2018-06-08  16:21:43 1. 创建存放软件文件夹 # cd / #mkdir a 2.下载MySQL5.6二进制包 cd a w ...

  4. MYSQL5.7二进制包的安装

    mysql5.7 二进制包安装1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_6 ...

  5. MariaDB二进制包简单安装部署

    一.简介: MySQL最早是由Michael Widenius在所研发,而在后来Michael先生以10亿美元的价格把MySQL卖给了SUN以后不久SUN就被Oracle公司给收购了,在Oracle收 ...

  6. Centos7.+系统,二进制包脚本安装Mysql

    #!/bin/bash #配置数据库要安装的目录,可以根据自己的安装路径修改PATHDIRPATHDIR="/project"BASEDIR="$PATHDIR/mysq ...

  7. 二进制包形式安装mysql5.7.17

    mysql5.7与mysql5.5的安装方式有些区别,如果按照5.5的方式来安装5.7就会有很多报错信息,下面介绍mysql5.7.17的二进制安装方式. 首先安装依赖包: yum -y instal ...

  8. MySQL5.7.20 二进制包无ROOT权限下安装, 滴滴云服务器

    01, 下载安装包 =>  https://dev.mysql.com/downloads/mysql/ 02, 上传到linux系统, 笔者这里使用的 滴滴云服务器 安装在 home/dc2- ...

  9. MYSQL5.5二进制包的安装

    二进制1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.5.55-linux2.6-i686.tar.gz2. 解压 tar xx ...

随机推荐

  1. xmlSerializer属性的使用

    学习了XmlAttribute,XmlElement属性的定义和使用. Order类定义 using System; using System.Collections.Generic; using S ...

  2. 一种提高Android应用进程存活率新方法

    一.基础知识 1.Android 进程优先级 1.1 进程优先级等级一般分法:- Activte process- Visible Process- Service process- Backgrou ...

  3. haskell处理JSON(aeson)

    aeson是haskell的一个库,其实我也不太懂,不过大概是这样的:   定义一个类型 如   data Person = Person { firstName :: String , lastNa ...

  4. cygwin设置

    解决乱码问题 # 设置为中文环境,使提示成为中文  export LANG =" zh_CN.UTF-8 " # 输出为中文编码  export OUTPUT_CHARSET =& ...

  5. Altium 原理图出现元件 “Extra Pin…in Normal of part ”警告

    原理是因为元器件库中的元器件的所有模式MODE不能和pcb中的引进匹配造成的,那什么又是MODE呢, 看下买的图便很清楚了, MODE可以理解为不同的视图模式吧. 然后赶紧打开原理图库中的有问题的元器 ...

  6. Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.Exec

    Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.tr ...

  7. dbgprint_Mine 调试输出

    void DbgPrintf_Mine(char*pszFormat,...) { #ifdef _DEBUG char szbufFormat[0x1000]; char szBufFormat_G ...

  8. springboot webapi 支持跨域 CORS

    1.创建corsConfig 配置文件 @Configuration public class corsConfig { @Autowired varModel varModel_; @Bean pu ...

  9. 在Visual Studio 2013 上开发Node.js程序

    [题外话] 最近准备用Node.js做些东西,于是找找看能否有Visual Studio上的插件以方便开发.结果还真找到了一个,来自微软的Node.js Tools for Visual Studio ...

  10. jcl sort comp3 to 表示型

    Lets say your packed data is at 10th column and is of length 6, S9(4)V99 You could try the following ...