mysql-学习-2
mysql-学习-20170426
mysql的安装:
如何下载mysql?
**切记需要从官网下载**

http://dev.mysql.com
mysql被Oracle收购后引入进来的一个版本概念: DMR
https://github.com/XX-net/XX-Net/wiki/%E4%BD%BF%E7%94%A8Chrome%E6%B5%8F%E8%A7%88%E5%99%A8
下载页面:
https://dev.mysql.com/downloads/mysql/

下载linux-generic 如果打不开,需要打开防火墙,因为被墙了! :(
就下载64位的:

ebc8cbdaa9c356255ef82bd989b07cfb mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
其他的下载源:


5.7版本后rpm包里面没有mysqld_safe这个命令了
这是和tar.gz包的区别

-------------安装MySQL---------------

安装mysql需要关闭numa,方法:

方法:numactl --show
pt命令
numactl命令 显示

rpm -qa |grep numa
希望看不到这个,mysql希望是一个node,所以要关闭numa
下面是oracle的在线关闭方法,

最好找运维维护窗口进行关闭numa

上面标记红色的两个参数对mysql影响很大,需要优化,
优化方法:
ulimit -Su 10000
也可以通过 /etc/security/limits.conf 修改这个文件进行调整
要么最多4G 足以
老师 发下你的终端提示符配置呗
【管理员】吴炳锡(82565387) 21:28:04
zst_ps1()
{
Date=$(date +%F)
Time=$(date +%H:%M:%S)
PS1="\\n\[\e[1;37m[\e[m\]\[\e[1;32m\u\e[m\]\[\e[1;33m@\e[m\]\[\e[1;35m\h $Time \e[m\]\e[1;36m`pwd`\e[m\e[1;37m]\e[m\n\\$"
}
PROMPT_COMMAND=zst_ps1
【管理员】吴炳锡(82565387) 21:28:14
/etc/profile
【管理员】吴炳锡(82565387) 21:28:19
source /etc/profile
sysctl.conf
【管理员】吴炳锡(82565387) 21:29:05
#vim /etc/sysctl.conf
【管理员】吴炳锡(82565387) 21:29:27
vm.swappiness=0
【管理员】吴炳锡(82565387) 21:29:40
tcp 连接回收及端口重用
【管理员】吴炳锡(82565387) 21:30:24
XFS
关闭selinux方法:setenforce 0
[client]
port = 3306
socket = /tmp/mysql.sock
[mysql]
prompt="\u@localhost \R:\m:\s [\d]> "
no-auto-rehash
[mysqld]
user = mysql
port = 3306
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3306/data
socket = /data/mysql/mysql.sock
pid-file = /data/mysql/mysql3306/data/mysql3306.pid
character-set-server = utf8mb4
skip_name_resolve = 1
open_files_limit = 65535
back_log = 1024
max_connections = 512
max_connect_errors = 1000000
table_open_cache = 1024
table_definition_cache = 1024
table_open_cache_instances = 64
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size = 768
query_cache_size = 0
query_cache_type = 0
interactive_timeout = 600
wait_timeout = 600
#default_table_type = DEFAULT_ENGINE
#default_table_type = InnoDB
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
slow_query_log_file = /data/mysql/mysql3306/data/slow.log
log-error = /data/mysql/mysql3306/data/error.log
long_query_time = 0.1
server-id = 3306
log-bin = /data/mysql/mybinlog
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
expire_logs_days = 7
master_info_repository = TABLE
relay_log_info_repository = TABLE
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
lock_wait_timeout = 3600
explicit_defaults_for_timestamp = 1
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
transaction_isolation = REPEATABLE-READ
#innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2867M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
innodb_log_file_size = 2G
innodb_log_files_in_group = 2
innodb_max_undo_log_size = 4G
# 根据您的服务器IOPS能力适当调整
# 一般配普通SSD盘的话,可以调整到 10000 - 20000
# 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_checksum_algorithm = crc32
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 4G
internal_tmp_disk_storage_engine = InnoDB
innodb_status_file = 1
innodb_status_output = 1
innodb_status_output_locks = 1
innodb_stats_on_metadata = 0
#performance_schema
performance_schema = 1
performance_schema_instrument = '%=on'
#innodb monitor
innodb_monitor_enable="module_innodb"
innodb_monitor_enable="module_server"
innodb_monitor_enable="module_dml"
innodb_monitor_enable="module_ddl"
innodb_monitor_enable="module_trx"
innodb_monitor_enable="module_os"
innodb_monitor_enable="module_purge"
innodb_monitor_enable="module_log"
innodb_monitor_enable="module_lock"
innodb_monitor_enable="module_buffer"
innodb_monitor_enable="module_index"
innodb_monitor_enable="module_ibuf_system"
innodb_monitor_enable="module_buffer_page"
innodb_monitor_enable="module_adaptive_hash"
[mysqldump]
quick
max_allowed_packet = 32M
[root@zst1 22:00:59 /usr/local/mysql]
#mysql
-bash: mysql: command not found
[root@zst1 22:01:56 /usr/local/mysql]
#echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@zst1 22:02:25 /usr/local/mysql]
#echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
[root@zst1 22:02:45 /usr/local/mysql]
#source /etc/profile
[root@zst1 22:02:49 /usr/local/mysql]
#
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
截图:

2017-05-01T09:04:21.517575Z 0 [ERROR] unknown variable 'default_table_type=DEFAULT_ENGINE'

(unknown)@localhost 17:44: [(none)]> ALTER USER USER() IDENTIFIED BY 'pgmfetion';
Query OK, 0 rows affected (0.02 sec)
创建新用户pgm:
root@localhost 17:48: [(none)]> grant all privileges on *.* to 'pgm'@'%' identified by 'pgmfetion' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.01 sec)
root@localhost 17:49: [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
----------------------------------------------------------------------------------------------------------------
浙公网安备 33010602011771号