您好,登录后才能下订单哦!
1.下载二进制文件并解压文件:
下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads
tar xvzf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.23-linux-glibc2.12-x86_64 /usr/local/
cd /usr/local/
ln -s mysql-5.7.23-linux-glibc2.12-x86_64 mysql
chown -R mysql:mysql /usr/local/mysql/
vim /etc/my.cnf
######################mysql5.7.23###############
[client]
port=3306
socket=/app/data/run/mysql.sock
[mysql]
#pid_file=/app/data/run/mysqld.pid
[mysqld]
gtid_mode=on
enforce_gtid_consistency=on
log_slave_updates=on
autocommit=1
general_log=off
explicit_defaults_for_timestamp=true
###character
default-storage-engine=INNODB
innodb_file_per_table=1
character-set-server=utf8
collation-server=utf8_general_ci
interactive_timeout = 559200
wait_timeout = 559200
# system
basedir=/usr/local/mysql
datadir=/app/data/data
max_allowed_packet=1g
max_connections=3000
max_user_connections=2800
open_files_limit=65535
pid_file=/app/data/run/mysqld.pid
port=3306
server_id=52160
#skip_name_resolve=ON
socket=/app/data/run/mysql.sock
tmpdir=/app/data/tmp
#innodb
innodb_data_home_dir=/app/data/log/iblog
innodb_log_group_home_dir=/app/data/log/iblog
innodb_buffer_pool_size = 1000M
#binlog
log_bin=/app/data/log/binlog/binlog
binlog_format=row
expire_logs_days=7
innodb_log_file_size = 200M
innodb_log_files_in_group = 4
max_binlog_size=200M
#logging
log_error=/app/data/log/error.log
slow_query_log_file=/app/data/log/slow.log
log_queries_not_using_indexes=0
slow_query_log=1
log_slave_updates=ON
log_slow_admin_statements=1
long_query_time=1
#relay
relay_log=/app/data/log/relaylog
relay_log_index=/app/data/log/relay.index
relay_log_info_file=/app/data/log/relay-log.info
[mysqld_safe]
datadir=/app/data/data
################mysql5.7.23##############
--添加用户:
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
---
或者直接:
useradd mysql
cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
--创建数据目录:
mkdir -p /app/data/log
mkdir -p /app/data/log/binlog
mkdir -p /app/data/run
mkdir -p /app/data/tmp
mkdir -p /app/data/log/iblog
chown -R mysql:mysql /app/data/
--初始化数据库:
[root@test1 ~]# su - mysql
[mysql@test1 ~]$ /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
2.1 通脚本启动:
启动数据库:
[mysql@test1 log]$ /etc/init.d/mysqld start
Starting MySQL.. [ OK ]
关闭数据库:
[mysql@test1 log]$ /etc/init.d/mysqld stop
Shutting down MySQL.. [ OK ]
登录数据库:
[mysql@test1 log]$ /usr/local/mysql/bin/mysql -uroot -p
修改密码:
mysql> alter user root@'localhost' identified by 'MYsql#123';
Query OK, 0 rows affected (0.00 sec)
2.2 自定义配置文件启动:
启动数据库:
[mysql@test1 log]$ /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
关闭数据库:
[mysql@test1 log]$ /usr/local/mysql/bin/mysqladmin --port=3306 shutdown -p
Enter password:
3.开机自动启动:
[root@test1 ~]# chkconfig mysqld on
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。