1 上传mysql安装包到linux服务器
tar -zxvf mysql-5.7.39-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.39-linux-glibc2.12-x86_64 mysql5.7
2  创建mysql用户
   groupadd mysql
   useradd -g mysql -s /sbin/nologin mysql
chown -R mysql:mysql mysql5.7

 

3  安装
  cd mysql5.7
  mkdir data
  cd bin
  ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql5.7/data/ --basedir=/usr/local/mysql5.7/
 
4 设置my.cnf配置文件

[client]
default-character-set=utf8
port=3306
socket=/tmp/mysql.sock

[mysqld]
socket=/tmp/mysql.sock
port=3306
basedir=/usr/local/mysql5.7
datadir=/usr/local/mysql5.7/data
pid-file=/usr/local/mysql5.7/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
skip-name-resolve
back_log = 600
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 100M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M

thread_cache_size = 8

query_cache_size = 8M
query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30

log_error=/usr/local/mysql5.7/data/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file=/usr/local/mysql5.7/data/mysql-slow.log

performance_schema = 0
explicit_defaults_for_timestamp

#lower_case_table_names = 1

skip-external-locking

default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G

interactive_timeout = 28800
wait_timeout = 28800
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M



##########################################################

 


 

5 设置环境变量

  vi /etc/profile
  设置PATH参数
  export PATH="$PATH:/usr/local/mysql5.7/bin/"

  source /etc/profile
6 测试 
 编辑 support-files/mysql.server
 设置以下配置参数
 basedir=/usr/local/mysql5.7
 datadir=/usr/local/mysql5.7/data
 
  //设置mysql 开机启动
  cp support-files/mysql.server /etc/init.d/mysqld
  chmod 755 /etc/init.d/mysqld
  chkconfig --add mysqld
  chkconfig mysqld on
  service mysqld restart

  mysql  -uoort -p

  FLUSH PRIVILEGES;
 //修改密码
  ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
 

 

posted on 2024-04-18 15:32  ヽ坚强的蘑菇  阅读(196)  评论(0编辑  收藏  举报