MySQL 安装:
操作系统:CentOS7.5
MySQL 版本:mysql-5.7.20-linux-glibc2.12-x86_64
安装前需要安装的库:
shell
sudo apt-get install libaio1
初始化
shell
cp -v share/english/errmsg.sys /usr/share/mysql/english/
# ln -s /usr/local/mysql/my.cnf /etc/mysql.cnf
# 配置文件略
# bin/mysql_install_db --defaults-file=/etc/my.cnf --datadir=/home/data/mysql/data
bin/mysqld --initialize
bin/mysqld --initialize --user jxft
A temporary password is generated for root@localhost: gnD.K;*i&0(%
部分辅助SQL:
sql
alter user user() identified by "root";
create user 'root'@'%' IDENTIFIED BY '123456';
grant all privileges on *.* to 'root'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER; #修改加密规则
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; #更新一下用户的密码
flush privileges;
# 密码的复杂度不符合默认规定,如下命令查看mysql默认密码复杂度:
set global validate_password_length=6;
登录信息
192.168.30.142 3306 root/123456
192.168.30.143 3306 root/123456
管理命令:
shell
安装路径:/usr/local/mysql
数据路径:/home/data/mysql/data
重启: mysql start|stop|restart 或 /usr/local/mysql/support-files/mysql.server start|stop|restart
优化参数(my.cnf):
ini
user=zhenqin
tmpdir=/tmp
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
bind-address=0.0.0.0
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir=/Volumes/Software/Program/mysql
#Path to the database root
datadir=/Volumes/Study/data/mysql
pid-file=/Volumes/Software/Program/mysql/zhenqin-mbp.pid
log-error=/Volumes/Study/data/mysql/mysql.err
language=/Volumes/Software/Program/mysql/share/english #此处为language配置项
socket=/Volumes/Software/Program/mysql/mysqld.sock
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
# The default storage engine that will be used when create new tables when
default-storage-engine=InnoDB
log-bin = mysql-bin
log-bin-index = mysql-bin.index
server-id = 1
# 不采用同步复制
# binlog_format=mixed
# 采用同步和复制,必须是ROWs
binlog_format = ROW
#必须是FULL
binlog_row_image = FULL
expire_logs_days = 3
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
key_buffer_size = 256M
max_allowed_packet = 16M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
# thread_concurrency = 8
thread_stack = 192K
thread_cache_size = 8
query_cache_limit = 1M
query_cache_size = 16M
expire_logs_days = 10
max_binlog_size = 100M
autocommit = 1
# 大小写不敏感
lower_case_table_names = 1
max_allowed_packet = 1024M
innodb_force_recovery = 0
log_bin_trust_function_creators = 1
default-time_zone = '+8:00'
max-connections = 1000