1. Mysql安装
1.命令: yum -yinstall zlib zlib-devel bzip2 bzip2-devel openssl openssl-devel xz-libs gccgcc-c++ pcre pcre-devel zlib libeventopenssl-clients nfs-utils rpcbind rsync ntpdate libselinux-python ncGraphicsMagick
2.命令:rpm-Uvh http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
命令:yuminstall mysql-community-server
用一下内容替换掉my.cnf中的内容:
命令:vi /etc/my.cnf
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set=utf8mb4
[mysqld]
datadir=/mysql_data
socket=/var/lib/mysql/mysql.sock
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
port = 3306
skip-external-locking= 1
#character set
character-set-client-handshake= FALSE
character-set-server= utf8mb4
collation-server= utf8mb4_unicode_ci
#configfor innodb
innodb_buffer_pool_instances=8
innodb_read_io_threads=20
innodb_write_io_threads=12
innodb_log_file_size= 1G
innodb_log_files_in_group= 3
innodb_log_buffer_size= 16M
innodb_flush_log_at_trx_commit= 2
innodb_lock_wait_timeout= 20
innodb_file_per_table=1
innodb_open_files=7000
#set70%~80% of memory
innodb_buffer_pool_size= 48G
innodb_thread_concurrency= 64
innodb_fast_shutdown=0
innodb_force_recovery=0
innodb_io_capacity= 1000
innodb_max_dirty_pages_pct=80
innodb_adaptive_flushing=0
innodb_old_blocks_time=20
innodb_autoinc_lock_mode=1
#configfor server
#100+ip
server-id = 100103
#disableipv6
bind-address= 0.0.0.0
explicit_defaults_for_timestamp=true
replicate-wild-ignore-table= test.%
#configbinlog for master
#binlog-do-db=esn
binlog-ignore-db= test
binlog-ignore-db= mysql
binlog-ignore-db= performance_schema
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
expire_logs_days=10
key_buffer_size= 128M
max_allowed_packet= 128M
binlog_cache_size=1M
table_open_cache= 2048
sort_buffer_size= 8M
join_buffer_size= 8M
read_buffer_size= 8M
read_rnd_buffer_size= 8M
bulk_insert_buffer_size= 32M
thread_stack=320k
tmp_table_size = 1024M
max_tmp_tables=1024
max_heap_table_size=256M
thread_cache_size= 128
query_cache_type=0
query_cache_size=1M
back_log= 500
slow_query_log= 1
long_query_time= 2
log_output= file
slow_query_log_file= /var/lib/mysql/slow.log
log_queries_not_using_indexes=0
log_slow_admin_statements = 1
log_slow_slave_statements = 1
lower_case_table_names=1
skip-name-resolve=1
max_connections= 6000
max_connect_errors= 20
connect-timeout=432000
interactive-timeout=432000
wait_timeout= 432000
max_binlog_size= 1G
max_relay_log_size= 1G
default_storage_engine= innodb
lock_wait_timeout= 20
slave_net_timeout=60
event_scheduler=1
log-bin=mysql-bin
binlog_format=row
[mysqld_safe]
open_files_limit= 65000
[mysqldump]
quick
max_allowed_packet= 128M
[mysql]
no-auto-rehash
default-character-set= utf8mb4
[myisamchk]
sort_buffer_size= 16M
read_buffer= 4M
write_buffer= 4M
[mysqlhotcopy]
interactive-timeout
3.initmysql with mysql user
#changeowner of data dir
命令:chown -R mysql:mysql/mysql_data
#init
命令:mysqld --initialize --user=mysql
#findtemp passoword for root
命令:sudo grep'temporary password'/var/log/mysqld.log
#用临时密码登录login
命令:mysql -uroot –p
#改密码
命令:ALTER USER'root'@'localhost' IDENTIFIED BY '123456';
# remotelogin
改完密码之后一定要进行授权:
命令:GRANT ALL PRIVILEGES ON*.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Reboot;重启机器
举例建立三个个默认库:
create databaseesn default charset utf8mb4;
create databasemobile_update defaultcharsetutf8mb4;
create databaseoauth defaultcharset utf8mb4;
问题:
出现此问题主要是授权不够:mysql启动不起来报错:
Job for mysqld.service failed because the controlprocess exited with error code. See"systemctl status mysqld.service" and"journalctl-xe" fordetails.
然后强制改密码:登录。
授权:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456'WITH GRANT OPTION;