Mysql 5.7.18 安裝部署mysql
#安裝好開發環境各類依賴包 yum groupinstall "Development tools" #安裝依賴包 yum search libaio # search for info yum install libaio # install library #新建用戶組和用戶 groupadd mysql useradd mysql -g mysql #創建存放數據庫目錄 mkdir /data #解壓包指定目錄 wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.18.tar.gz wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-i686.tar.gz 【625M mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz】 這裏使用官網編譯好的二進制安裝包 tar xf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /data #重名名 mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql5.7 #安裝 mkdir -p /data/mysql/data #更改全部者 chown -R mysql:mysql /data/ #初始化數據庫 /data/mysql/bin/mysqld --user=mysql --basedir=/data/mysql/ --datadir=/data/mysql/data --initialize 初始化後記下mysql root用戶隨機產生的密碼 pychBtXfV3-A [見底部圖片樣例] #拷貝啓動程序文件到/etc/init.d/下面 cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld #修改啓動腳本文件 vim /etc/init.d/mysqld 修改66-73 行 的mysql程序路徑 爲咱們自定義的路徑 修改前: basedir=/usr/local/mysql bindir=/usr/local/mysql/bin if test -z "$datadir" then datadir=/usr/local/mysql/data fi sbindir=/usr/local/mysql/bin libexecdir=/usr/local/mysql/bin 修改後: … 66 basedir=/data/mysql 67 bindir=/data/mysql/bin 68 if test -z "$datadir" 69 then 70 datadir=/data/mysql/data 71 fi 72 sbindir=/data/mysql/bin 73 libexecdir=/data/mysql/bin … #先清理一下內存 sync echo 3 > /proc/sys/vm/drop_caches #配置my.cnf [client] #no-beep socket =/data/mysql/mysql.sock # pipe # socket=0.i0 port=3306 [mysql] default-character-set=utf8 [mysqld] basedir=/data/mysql datadir=/data/mysql/data port=3306 pid-file=/data/mysql/mysqld.pid #skip-grant-tables skip-name-resolve socket = /data/mysql/mysql.sock character-set-server=utf8 default-storage-engine=INNODB explicit_defaults_for_timestamp = true # Server Id server-id=1 max_connections=2000 query_cache_size=0 table_open_cache=2000 tmp_table_size=246M thread_cache_size=300 #限定用於每一個數據庫線程的棧大小。默認設置足以知足大多數應用 thread_stack = 192k key_buffer_size=512M read_buffer_size=4M read_rnd_buffer_size=32M innodb_data_home_dir = /data/mysql/data innodb_flush_log_at_trx_commit=0 innodb_log_buffer_size=16M innodb_buffer_pool_size=256M innodb_log_file_size=128M innodb_thread_concurrency=128 innodb_autoextend_increment=1000 innodb_buffer_pool_instances=8 innodb_concurrency_tickets=5000 innodb_old_blocks_time=1000 innodb_open_files=300 innodb_stats_on_metadata=0 innodb_file_per_table=1 innodb_checksum_algorithm=0 back_log=80 flush_time=0 join_buffer_size=128M max_allowed_packet=1024M max_connect_errors=2000 open_files_limit=4161 query_cache_type=0 sort_buffer_size=32M table_definition_cache=1400 binlog_row_event_max_size=8K sync_master_info=10000 sync_relay_log=10000 sync_relay_log_info=10000 #批量插入數據緩存大小,能夠有效提升插入效率,默認爲8M bulk_insert_buffer_size = 64M interactive_timeout = 120 wait_timeout = 120 log-bin-trust-function-creators=1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #啓動mysql Service mysqld start #增長環境變量 vim /etc/profile 最下面加上: export PATH=${PATH}:/data/mysql/bin #使環境變量生效 source /etc/profile 或者 . /etc/profile #修改密碼 mysql –uroot –p 【密碼爲初始化數據庫時給出的隨機密碼】 #修改密碼,否則沒法執行mysql相關命令操做 mysql>SET PASSWORD = PASSWORD('root');
圖爲初始化的時候:linux