CentOS7最小安装mysql

时间:2022-11-19 04:57:54
CentOS7最小安装mysql


1.安装CentOS-7-x86_64-DVD-1511.iso。
  最小安装方式。建议添加开发工具,samba和文件共享。
  安装的时候选择静态IP地址,录入机器名


2.安装网络工具包
  yum install net-tools


  如果安装时为动态IP方式,则需要手工修改IP地址为静态,同时修改主机名


3.安装vmtools
  mount -t auto /dev/cdrom /mnt/cdrom 
  cp /mnt/cdrom/VMwareTools-10.0.10-4301679.tar.gz /root
  tar zxvf VMwareTools-10.0.10-4301679.tar.gz
  cd vmware-tools-distrib
  ./vmware-install.pl
  rm -rf vmware-tools-distrib


4.更新或升级最小化安装的 CentOS
  yum update && yum upgrade


5.添加163镜像源
  #mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  cd /etc/yum.repos.d/
  wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
  yum clean all
  yum makecache


5.安装mysql
  sudo rpm -Uvh mysql57-community-release-el7-9.noarch.rpm
  sudo yum install mysql-community-server
  vi /etc/my.cnf


#添加以下内容
log_bin_trust_function_creators=1  
character-set-server=utf8
lower_case_table_names=1


plugin-load=validate_password.so
validate-password=FORCE_PLUS_PERMANENT

sql_mode='ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,
NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,
NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES'



max_connections=4000
key_buffer_size=200M
low_priority_updates=1
table_open_cache=8000
back_log=1500
query_cache_type=0
table_open_cache_instances=16


# files
innodb_file_per_table
innodb_log_file_size=200M
innodb_log_files_in_group=3
innodb_open_files=4000


# buffers
innodb_buffer_pool_size=1024M
innodb_buffer_pool_instances=32
#innodb_additional_mem_pool_size=20M
innodb_log_buffer_size=64M
join_buffer_size=32K
sort_buffer_size=32K


# innodb
innodb_checksums=0
innodb_doublewrite=0
innodb_support_xa=0
innodb_thread_concurrency=0
innodb_flush_log_at_trx_commit=2
innodb_max_dirty_pages_pct=50
innodb_use_native_aio=1
innodb_stats_persistent=1
innodb_spin_wait_delay=16 #6/96


# perfspecial
innodb_adaptive_flushing=1
innodb_flush_neighbors=0
innodb_read_io_threads=4
innodb_write_io_threads=4
innodb_io_capacity=400
innodb_purge_threads=1
innodb_adaptive_hash_index=0


# monitoring
innodb_monitor_enable='%'
performance_schema=OFF


  sudo service mysqld start
  grep 'temporary password' /var/log/mysqld.log | awk '{print $11}'
  mysql -uroot -p
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
    use mysql
    update user set host = '%' where user = 'root';
    flush privileges;
  exit
  iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
  service iptables restart
  service iptables stop
  service firewalld stop
  #systemctl disable firewalld.service
  #systemctl disable iptables.service