二进制安装mysql5.7

1.解压

mkdir /opt/mysql

mv mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz /opt/mysql/

cd /opt/mysql

tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

2.创建一个链接

cd /usr/local

ln -s /opt/mysql/mysql-5.7.16-linux-glibc2.5-x86_64  mysql

3.创建运行的用户

groupadd mysql

useradd -g mysql -d /usr/local/mysql -s /sbin/nologin -M -n mysql

4.创建所需要的目录

mkdir -p /data/mysql/3306/{data,logs,tmp}

5.修改权限

chown -R mysql:mysql /data/mysql/3306/

chown -R mysql:mysql /usr/local/mysql/

6,修改配置文件

vi /data/mysql/3306/my3306.cnf

#my.cnf
[client]
port            = 3306
socket          = /data/mysql/3306/tmp/3306.sock

[mysql]
prompt="\\[email protected]\\h:\\p [\\d]>"
#pager="less -i -n -S"
#tee=/opt/mysql/query.log
no-auto-rehash

[mysqld]
#misc
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/3306/data
port = 3306
socket = /data/mysql/3306/tmp/3306.sock
event_scheduler = 0

tmpdir = /data/mysql/3306/tmp
#timeout
interactive_timeout = 300
wait_timeout = 300

#character set
character-set-server = utf8

open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000
lower_case_table_names =1

#symi replication

#rpl_semi_sync_master_enabled=1
#rpl_semi_sync_master_timeout=1000 # 1 second
#rpl_semi_sync_slave_enabled=1

#logs
log-output=file
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
log_warnings = 2
pid-file = mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1

#binlog
#binlog_format = STATEMENT
binlog_format = row
server-id = 330627
log-bin = /data/mysql/3306/logs/mysql-bin
binlog_cache_size = 4M
max_binlog_size = 256M
max_binlog_cache_size = 1M
sync_binlog = 0
expire_logs_days = 10
#procedure
log_bin_trust_function_creators=1

#
#gtid-mode = on
#enforce-gtid-consistency=1

#relay log
skip_slave_start = 1
max_relay_log_size = 128M
relay_log_purge = 1
relay_log_recovery = 1
relay-log=relay-bin
relay-log-index=relay-bin.index
log_slave_updates
#slave-skip-errors=1032,1053,1062
#skip-grant-tables

#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 128K
join_buffer_size = 128K
thread_cache_size = 200
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M

#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

#innodb
innodb_buffer_pool_size = 100M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:100M:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 8M
innodb_log_file_size = 100M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 100
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT

7.初始化

chown mysql:mysql  /data/mysql/3306/my3306.cnf

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

注意:--initilize 参数需要放在最后,--initialize会显示密码, --initialize-insecure  密码为空。

8.设置mysql变量

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

source /etc/profile

9.启动MySQL

mysqld --defaults-file=/data/mysql/3306/my3306.cnf &

10.修改密码

cat /data/mysql/3306/data/error.log |grep "password"

alter user user() identified by ‘oracle‘;

多实例安装

mkdir ./3307/{data,logs,tmp} -p

chown -R mysql:mysql 3307

cp ./3306/my3306.cnf ./3307/my3307.cnf

sed -i ‘s/3306/3307/g‘ ./3307/my3307.cnf

chown mysql:mysql  /data/mysql/3307/my3307.cnf

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

时间: 2024-10-13 09:38:25

二进制安装mysql5.7的相关文章

轻松使用二进制安装Mysql5.6

二进制安装mysql5.6 系统环境:Centos6.5 x86_64 mysql二进制包:mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz #解压tar包到指定安装目录: cp mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz /data/ tar -zxf /data/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz #创建mysql数据存储目录 mkdir /data/mysqldata

二进制安装mysql5.6.39报错找不到libnuma.so.1库文件

二进制安装mysql5.6.39初始化时报错如下: [[email protected] scripts]# ./mysql_install_db --datadir=/data/mysql/data --basedir=/usr/local/mysql --user=mysql --explicit_defaults_for_timestamp Installing MySQL system tables.../usr/local/mysql/bin/mysqld: error while l

二进制安装MySQL-5.5.33

二进制安装MySQL很方便,相比较编译安装,美中不足的就是安装包太大了.哈哈 开始安装,首先养成好习惯,创建一个专门存放安装包的目录 mkdir -p /home/yuci/tools 安装 lrzsz 可以在xshell下直接将安装包拖拽到指定目录下 yum -y install lrzsz 将 mysql 安装包拖拽到 /home/yuci/tools 目录下,解压就OK了 cd /home/yuci/tools/ tar zxf mysql-5.5.33-linux2.6-x86_64.t

centos 6.5 二进制安装mysql5.6

1.官网下载mysql 二进制包,mysql5.6 ,并上传到/usr/local 目录下. 2.解压安装,改名mysql 3.创建mysql 用户和组,更改所有者和所属组 5.初始化 6.copy my.cnf 到/etc/my.cnf 7.编辑/etc/my.cnf 8.rm -rf my.cnf 9.设置service 启动 10.设置环境变量,可做软连或cp 11.mysql 启动 12.登陆mysql

二进制安装mysql5.5.32

1:下载二进制mysql-5.5.32-linux2.6-x86_64.tar.gz包wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz 2:解压tar zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz 3:移动到指定目录mv mysql-5.5.32-linux2.6-x86_64 /application/ 4:创建软链接ln -s /app

CentOS 7.2二进制安装mysql-5.7.19

官方文档地址:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html 开始安装 1.下载mysql二进制包 # cd /usr/local/src # wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz 2.下载mysql依赖的libaio 库 # yum search libaio #

Centos7 二进制安装mysql5.7

安装环境 系统版本:CentOS Linux release 7.5.1804 (Core) Mysql版本:5.7.24 关闭防火墙并禁止开机自启 systemctl stop firewalld.servicesystemctl disable firewalld 关闭selinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux 重启 reboot 安装mysql 1.卸载自带数据库mariadb

二进制安装MySQL5.5.39,磁盘空间不足导致MySQL无法启动

--添加用户和组 [[email protected] local]# groupadd [[email protected] local]# useradd -g mysql -s /sbin/nologin -d /opt/msyql mysql --创建目录 [[email protected] local]# mkdir /data/mysql/mysql_3306/{data,logs,tmp} -p --做软链接到/usr/local/mysql [[email protected]

Linux CentOS7.5上二进制安装MySQL5.7.23

1.下载二进制文件 cd /usr/local/src/ wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz 2.创建MySQL组和用户 groupadd mysql useradd -g mysql mysql passwd mysql 3.创建安装目录.数据目录.配置目录等 mkdir -p /usr/local/mysql/ mkdir -p /usr/loca