mysql 5.7.18部署note

---

tar -zxf mysql-xxx.gz
cp -r mysql-xx  /usr/local/mysql
cd /usr/local/mysql/bin

mkdir -pv /data/mysql/{log,run,tmp,data}
mkdir -pv /data/mysql/log/{iblog,binlog}

chown -R  mysql.mysql /data/mysql/{log,run,tmp,data}


# initialize, the [---password---] will print in screen
./mysqld  --defaults-file=/data/mysql/my.cnf --initialize --datadir=/data/mysql/data --basedir=/usr/local/mysql --user=mysql

flush privileges;
ERROR 1146 (42S02): Table mysql.servers doesnt exist
mysql> drop table if exists mysql.servers;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE `servers` (
    ->         `Server_name` char(64) NOT NULL,
    ->         `Host` char(64) NOT NULL,`Db` char(64) NOT NULL,
    ->         `Username` char(64) NOT NULL,
    ->         `Password` char(64) NOT NULL,
    ->         `Port` int(4) DEFAULT NULL,
    ->         `Socket` char(64) DEFAULT NULL,
    ->         `Wrapper` char(64) NOT NULL,
    ->         `Owner` char(64) NOT NULL,
    ->         PRIMARY KEY (`Server_name`)
    ->         ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=MySQL Foreign Servers table
    -> ;
Query OK, 0 rows affected (0.02 sec)

mysql>


# start mysql
/mysqld_safe   --defaults-file=/data/mysql/my.cnf



update password
mysql -uroot -p [---password---] -S /data/mysql/run/mysql.sock
alter user user() identified by "root";
update mysql.user set authentication_string=password(123456) where user=root ;



mysql -uroot -proot -S /data/mysql/run/mysql.sock
create table test(id int,name varchar(18));insert into test values(1,rainman)







[root@localhost ~]# ll /data/mysql/
total 52
drwxr-xr-x  2 root  root   4096 Jul  8 11:33 bin
-rw-r--r--  1 root  root  17987 Mar 18  2017 COPYING
drwxr-xr-x  5 mysql mysql  4096 Jul  8 11:54 data
drwxr-xr-x  2 root  root     52 Jul  8 11:33 docs
drwxr-xr-x  3 root  root   4096 Jul  8 11:33 include
drwxr-xr-x  5 root  root   4096 Jul  8 11:33 lib
drwxr-xr-x  4 mysql mysql    62 Jul  8 11:54 log
drwxr-xr-x  4 root  root     28 Jul  8 11:33 man
-rw-r--r--  1 root  root   3595 Jul  8 11:43 my.cnf
-rw-r--r--  1 root  root   3585 Jul  8 11:34 my.cnf~
-rw-r--r--  1 root  root   2478 Mar 18  2017 README
drwxr-xr-x  2 mysql mysql    62 Jul  8 11:54 run
drwxr-xr-x 28 root  root   4096 Jul  8 11:33 share
drwxr-xr-x  2 root  root     86 Jul  8 11:33 support-files
drwxr-xr-x  2 mysql mysql     6 Jul  8 11:54 tmp

 

 

 

  1 # For advice on how to change settings please see
  2 # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
  3 # *** DO NOT EDIT THIS FILE. Its a template which will be copied to the
  4 # *** default location during install, and will be replaced if you
  5 # *** upgrade to a newer version of MySQL.
  6 
  7 [mysqld]
  8 user=mysql
  9 # Remove leading # and set to the amount of RAM for the most important data
 10 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
 11 # innodb_buffer_pool_size = 128M
 12 
 13 # Remove leading # to turn on a very important data integrity option: logging
 14 # changes to the binary log between backups.
 15 # log_bin
 16 
 17 # These are commonly set, remove the # and set as required.
 18 # basedir = .....
 19 # datadir = .....
 20 # port = .....
 21 # server_id = .....
 22 # socket = .....
 23 
 24 # Remove leading # to set options mainly useful for reporting servers.
 25 # The server defaults are faster for transactions and fast SELECTs.
 26 # Adjust sizes as needed, experiment to find the optimal values.
 27 # join_buffer_size = 128M
 28 # sort_buffer_size = 2M
 29 # read_rnd_buffer_size = 2M 
 30 #skip-grant-tables
 31 
 32 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 33 [client]
 34 port = 3307
 35 socket =/data/mysql/run/mysql.sock
 36 #default-character-set=utf8
 37 
 38 [mysql]
 39 #no-auto-rehash
 40 #default-character-set=utf8
 41 
 42 [mysqld]
 43 ## enable autocommit
 44 autocommit=1
 45 general_log=off
 46 explicit_defaults_for_timestamp=true
 47 character_set_server = gbk
 48 auto_increment_increment= 2
 49 auto_increment_offset   = 1
 50 
 51 # system
 52 basedir=/data/mysql
 53 datadir=/data/mysql/data/
 54 max_allowed_packet=134217728
 55 max_connections=8192
 56 max_user_connections=8000
 57 open_files_limit=65535
 58 pid_file=/data/mysql/run/mysqld.pid
 59 port=3307
 60 server_id=128
 61 skip_name_resolve=ON
 62 socket=/data/mysql/run/mysql.sock
 63 tmpdir=/data/mysql/tmp
 64 
 65 # binlog
 66 binlog_cache_size=32768
 67 binlog_format=row
 68 expire_logs_days=15
 69 log-bin=/data/mysql/log/binlog/master-bin
 70 log-bin-index=/data/mysql/log/binlog/master-bin.index
 71 log_slave_updates=ON
 72 max_binlog_cache_size=2147483648
 73 max_binlog_size=524288000
 74 sync_binlog=100
 75 
 76 #relay
 77 
 78 # LOGGING #
 79 log_error                      = /data/mysql/log/alert.log
 80 log_queries_not_using_indexes  = 1
 81 slow_query_log                = 1
 82 slow_query_log_file            = /data/mysql/log/slow.log
 83 log_slave_updates=ON
 84 log_slow_admin_statements=1
 85 long_query_time=1
 86 
 87 #slave#
 88 slave_skip_errors=OFF
 89 log_slave_updates=ON
 90 
 91 # innodb #
 92 innodb_log_group_home_dir=/data/mysql/log/iblog
 93 innodb_data_home_dir=/data/mysql/log/iblog
 94 innodb_adaptive_flushing=1
 95 #innodb_additional_mem_pool_size=20M
 96 innodb_buffer_pool_instances=8
 97 innodb_change_buffering=inserts
 98 innodb_data_file_path=ibdata1:32M;ibdata2:16M:autoextend
 99 innodb_flush_method            = O_DIRECT
100 innodb_log_files_in_group      = 4
101 innodb_log_file_size          = 100M
102 innodb_flush_log_at_trx_commit = 1
103 innodb_file_per_table          = 1
104 innodb_buffer_pool_size        = 128M
105 innodb_file_format=Barracuda
106 #innodb_file_io_threads=4
107 innodb_flush_neighbors=0
108 innodb_io_capacity=200
109 innodb_lock_wait_timeout=5
110 innodb_log_buffer_size=64M
111 innodb_lru_scan_depth=2048
112 innodb_max_dirty_pages_pct=60
113 innodb_old_blocks_time=1000
114 innodb_online_alter_log_max_size=200M
115 innodb_open_files=200
116 innodb_print_all_deadlocks=1
117 innodb_purge_threads=4
118 innodb_read_ahead_threshold=0
119 innodb_read_io_threads=8
120 innodb_rollback_on_timeout=0
121 innodb_sort_buffer_size=2M
122 innodb_spin_wait_delay=6
123 innodb_stats_on_metadata=0
124 innodb_strict_mode=1
125 innodb_sync_array_size=256
126 innodb_sync_spin_loops=30
127 innodb_thread_concurrency=64
128 innodb_use_native_aio=0
129 innodb_write_io_threads=8
130 innodb_support_xa=1
131 
132 [mysqld_safe]
133 datadir=/data/mysql/data/

 

mysql 5.7.18部署note

上一篇:plsql 恢复文件


下一篇:docker 搭建Mycat环境实现Mysql数据库的读写分离