1. 程式人生 > >mysql 5.6_38 linux 安裝

mysql 5.6_38 linux 安裝

刪除老版本:

檢視安裝包:

[[email protected] opt]# rpm -qa | grep -i mysql

mysql-libs-5.1.73-7.el6.x86_64

mysql-server-5.1.73-7.el6.x86_64

zabbix-server-mysql-2.4.8-1.el6.x86_64

perl-DBD-MySQL-4.013-3.el6.x86_64

mysql-devel-5.1.73-7.el6.x86_64

php-mysql-5.3.3-48.el6_8.x86_64

zabbix-web-mysql-2.4.8-1.el6.noarch

mysql-5.1.73-7.el6.x86_64

[[email protected] opt]#

 

關閉mysql服務:

[[email protected] opt]# /etc/init.d/mysqld  stop

Stopping mysqld:                                          [  OK  ]

[[email protected] opt]#

[[email protected] opt]#  chkconfig --list | grep -i mysql

mysqld            0:off 1:off 2:off 3:off 4:off 5:off 6:off

[[email protected] opt]#

 

 

收集mysql對應的資料夾資訊:

[[email protected]

opt]# whereis mysql

mysql: /usr/bin/mysql /usr/lib64/mysql/usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

[[email protected] opt]#

 

[[email protected] opt]# find / -name mysql

/usr/lib64/perl5/DBD/mysql

/usr/lib64/perl5/auto/DBD/mysql

/usr/lib64/mysql

/usr/share/doc/zabbix-server-mysql-2.4.8/upgrades/dbpatches/2.0/mysql

/usr/share/doc/zabbix-server-mysql-2.4.8/upgrades/dbpatches/1.6/mysql

/usr/share/doc/zabbix-server-mysql-2.4.8/upgrades/dbpatches/1.8/mysql

/usr/share/mysql

/usr/include/mysql

/usr/bin/mysql

/var/lib/mysql

/var/lib/mysql/mysql

[[email protected] opt]#

 

刪除rpm:

 

[[email protected] opt]# rpm -ev  mysql-devel-5.1.73-7.el6.x86_64

[[email protected] opt]#  rpm -ev mysql-server-5.1.73-7.el6.x86_64

warning: /var/log/mysqld.log saved as/var/log/mysqld.log.rpmsave

[[email protected] opt]# rpm -ev  mysql-5.1.73-7.el6.x86_64

 

刪除資料夾:

[[email protected] opt]# rm -rf /var/lib/mysql/

[[email protected] opt]# rm -rf/usr/lib64/mysql/

[[email protected] opt]#

刪除使用者:

[[email protected] opt]# userdel -r mysql

userdel: mysql mail spool(/var/spool/mail/mysql) not found

userdel: mysql home directory(/var/lib/mysql) not found

[[email protected] opt]#

 

安裝:

 

建立使用者:

 

[[email protected] ~]# groupadd mysql

[[email protected] ~]# useradd -r -g mysql mysql

 

解壓軟體:

[[email protected] opt]# cpmysql-5.6.38-linux-glibc2.12-x86_64.tar.gz /usr/local/

[[email protected] local]# tar -zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz

[[email protected] local]# mvmysql-5.6.38-linux-glibc2.12-x86_64 mysql5.638

修改許可權:

[[email protected] local]# chown -R mysql:mysqlmysql5.638/

初始化資料庫:

[[email protected] mysql5.638]# cd scripts/

[[email protected] scripts]# ll

total 36

-rwxr-xr-x 1 mysql mysql 34558 Sep 14 00:24mysql_install_db

[[email protected] scripts]#

[[email protected] scripts]# ./mysql_install_db--user=mysql --basedir=/usr/local/mysql5.638/ --datadir=/data/mysql5630/data/

WARNING: The host 'centos1' could not belooked up with /usr/local/mysql5.638//bin/resolveip.

This probably means that your libclibraries are not 100 % compatible

with this binary MySQL version. The MySQLdaemon, mysqld, should work

normally with the exception that host nameresolving will not work.

This means that you should use IP addresses instead of hostnames

when specifying MySQL privileges !

 

Installing MySQL system tables...2017-10-1922:58:01 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (see documentationfor more details).

2017-10-19 22:58:01 0 [Note] Ignoring--secure-file-priv value as server is running with --bootstrap.

2017-10-19 22:58:01 0 [Note]/usr/local/mysql5.638//bin/mysqld (mysqld 5.6.38) starting as process 5797 ...

2017-10-19 22:58:01 5797 [Note] InnoDB:Using atomics to ref count buffer pool pages

2017-10-19 22:58:01 5797 [Note] InnoDB: TheInnoDB memory heap is disabled

2017-10-19 22:58:01 5797 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins

2017-10-19 22:58:01 5797 [Note] InnoDB:Memory barrier is not used

2017-10-19 22:58:01 5797 [Note] InnoDB:Compressed tables use zlib 1.2.3

2017-10-19 22:58:01 5797 [Note] InnoDB:Using Linux native AIO

2017-10-19 22:58:01 5797 [Note] InnoDB:Using CPU crc32 instructions

2017-10-19 22:58:01 5797 [Note] InnoDB:Initializing buffer pool, size = 128.0M

2017-10-19 22:58:01 5797 [Note] InnoDB:Completed initialization of buffer pool

2017-10-19 22:58:01 5797 [Note] InnoDB: Thefirst specified data file ./ibdata1 did not exist: a new database to becreated!

2017-10-19 22:58:01 5797 [Note] InnoDB:Setting file ./ibdata1 size to 12 MB

2017-10-19 22:58:01 5797 [Note] InnoDB:Database physically writes the file full: wait...

2017-10-19 22:58:02 5797 [Note] InnoDB:Setting log file ./ib_logfile101 size to 48 MB

2017-10-19 22:58:03 5797 [Note] InnoDB:Setting log file ./ib_logfile1 size to 48 MB

2017-10-19 22:58:05 5797 [Note] InnoDB:Renaming log file ./ib_logfile101 to ./ib_logfile0

2017-10-19 22:58:05 5797 [Warning] InnoDB:New log files created, LSN=45781

2017-10-19 22:58:05 5797 [Note] InnoDB:Doublewrite buffer not found: creating new

2017-10-19 22:58:05 5797 [Note] InnoDB:Doublewrite buffer created

2017-10-19 22:58:05 5797 [Note] InnoDB: 128rollback segment(s) are active.

2017-10-19 22:58:05 5797 [Warning] InnoDB:Creating foreign key constraint system tables.

2017-10-19 22:58:05 5797 [Note] InnoDB:Foreign key constraint system tables created

2017-10-19 22:58:05 5797 [Note] InnoDB:Creating tablespace and datafile system tables.

2017-10-19 22:58:05 5797 [Note] InnoDB:Tablespace and datafile system tables created.

2017-10-19 22:58:05 5797 [Note] InnoDB:Waiting for purge to start

2017-10-19 22:58:05 5797 [Note] InnoDB:5.6.38 started; log sequence number 0

2017-10-19 22:58:06 5797 [Note] Binlog end

2017-10-19 22:58:06 5797 [Note] InnoDB: FTSoptimize thread exiting.

2017-10-19 22:58:06 5797 [Note] InnoDB:Starting shutdown...

2017-10-19 22:58:07 5797 [Note] InnoDB:Shutdown completed; log sequence number 1625977

OK

 

Filling help tables...2017-10-19 22:58:07 0[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).

2017-10-19 22:58:07 0 [Note] Ignoring--secure-file-priv value as server is running with --bootstrap.

2017-10-19 22:58:07 0 [Note]/usr/local/mysql5.638//bin/mysqld (mysqld 5.6.38) starting as process 5819 ...

2017-10-19 22:58:07 5819 [Note] InnoDB:Using atomics to ref count buffer pool pages

2017-10-19 22:58:07 5819 [Note] InnoDB: TheInnoDB memory heap is disabled

2017-10-19 22:58:07 5819 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins

2017-10-19 22:58:07 5819 [Note] InnoDB:Memory barrier is not used

2017-10-19 22:58:07 5819 [Note] InnoDB:Compressed tables use zlib 1.2.3

2017-10-19 22:58:07 5819 [Note] InnoDB:Using Linux native AIO

2017-10-19 22:58:07 5819 [Note] InnoDB:Using CPU crc32 instructions

2017-10-19 22:58:07 5819 [Note] InnoDB:Initializing buffer pool, size = 128.0M

2017-10-19 22:58:07 5819 [Note] InnoDB:Completed initialization of buffer pool

2017-10-19 22:58:07 5819 [Note] InnoDB:Highest supported file format is Barracuda.

2017-10-19 22:58:07 5819 [Note] InnoDB: 128rollback segment(s) are active.

2017-10-19 22:58:07 5819 [Note] InnoDB:Waiting for purge to start

2017-10-19 22:58:07 5819 [Note] InnoDB:5.6.38 started; log sequence number 1625977

2017-10-19 22:58:07 5819 [Note] Binlog end

2017-10-19 22:58:07 5819 [Note] InnoDB: FTSoptimize thread exiting.

2017-10-19 22:58:07 5819 [Note] InnoDB:Starting shutdown...

2017-10-19 22:58:09 5819 [Note] InnoDB:Shutdown completed; log sequence number 1625987

OK

 

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

 

PLEASE REMEMBER TO SET A PASSWORD FOR THEMySQL root USER !

To do so, start the server, then issue thefollowing commands:

 

 /usr/local/mysql5.638//bin/mysqladmin -u root password 'new-password'

 /usr/local/mysql5.638//bin/mysqladmin -u root -h centos1 password'new-password'

 

Alternatively you can run:

 

 /usr/local/mysql5.638//bin/mysql_secure_installation

 

which will also give you the option ofremoving the test

databases and anonymous user created bydefault.  This is

strongly recommended for productionservers.

 

See the manual for more instructions.

 

You can start the MySQL daemon with:

 

  cd. ; /usr/local/mysql5.638//bin/mysqld_safe &

 

You can test the MySQL daemon with mysql-test-run.pl

 

  cdmysql-test ; perl mysql-test-run.pl

 

Please report any problems athttp://bugs.mysql.com/

 

The latest information about MySQL isavailable on the web at

 

 http://www.mysql.com

 

Support MySQL by buying support/licenses athttp://shop.mysql.com

 

New default config file was created as/usr/local/mysql5.638//my.cnf and

will be used by default by the server whenyou start it.

You may edit this file to change serversettings

 

WARNING: Default config file /etc/my.cnfexists on the system

This file will be read by default by theMySQL server

If you do not want to use this, eitherremove it, or use the

--defaults-file argument to mysqld_safewhen starting the server

 

[[email protected] scripts]#

 

 

配置檔案:

[[email protected] scripts]# cd/usr/local/mysql5.638/support-files

#cp my-default.cnf/etc/my.cnf

cp mysql.server /etc/init.d/mysql

#my.cnf

[client]

port            = 3306

socket          = /tmp/mysql.sock

 

[mysql]

prompt="\\[email protected]\\h [\\d]>"

#pager="less -i -n -S"

#tee=/opt/mysql/query.log

no-auto-rehash

 

[mysqld]

#misc

user = mysql

basedir = /usr/local/mysql5.638

datadir = /data/mysql5630/data

port = 3306

 

socket = /tmp/mysql3306.sock

event_scheduler = 0

 

tmpdir = /data/mysql5630/tmp

#timeout

interactive_timeout = 300

wait_timeout = 300

 

#character set

character-set-server = utf8

 

open_files_limit = 65535

max_connections = 100

max_connect_errors = 100000

lower_case_table_names =1

 

#symi replication

 

#rpl_semi_sync_master_enabled=1

#rpl_semi_sync_master_timeout=1000 # 1second

#rpl_semi_sync_slave_enabled=1

 

#logs

log-output=file

slow_query_log = 1

slow_query_log_file = slow.log

log-error = error.log

log_warnings = 2

pid-file = mysql.pid

long_query_time = 1

#log-slow-admin-statements = 1

#log-queries-not-using-indexes = 1

log-slow-slave-statements = 1

 

#binlog

#binlog_format = STATEMENT

binlog_format = row

server-id = 1003306

log-bin = /data/mysql5630/logs/mysql-bin

max_binlog_size = 256M

sync_binlog = 0

expire_logs_days = 10

#procedure

log_bin_trust_function_creators=1

 

#

gtid-mode = on

enforce-gtid-consistency=1

 

 

#relay log

skip_slave_start = 1

max_relay_log_size = 128M

relay_log_purge = 1

relay_log_recovery = 1

relay-log=relay-bin

relay-log-index=relay-bin.index

log_slave_updates

#slave-skip-errors=1032,1053,1062

#skip-grant-tables

 

#buffers & cache

table_open_cache = 2048

table_definition_cache = 2048

table_open_cache = 2048

max_heap_table_size = 96M

sort_buffer_size = 128K

join_buffer_size = 128K

thread_cache_size = 200

query_cache_size = 0

query_cache_type = 0

query_cache_limit = 256K

query_cache_min_res_unit = 512

thread_stack = 192K

tmp_table_size = 96M

key_buffer_size = 8M

read_buffer_size = 2M

read_rnd_buffer_size = 16M

bulk_insert_buffer_size = 32M

 

#myisam

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

 

#innodb

innodb_buffer_pool_size = 100M

innodb_buffer_pool_instances = 1

innodb_data_file_path =ibdata1:100M:autoextend

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 8M

innodb_log_file_size = 100M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 50

innodb_file_per_table = 1

innodb_rollback_on_timeout

innodb_io_capacity = 2000

transaction_isolation = READ-COMMITTED

innodb_flush_method = O_DIRECT

 

 

 

配置環境變數

 

vim /etc/profile

exportMYSQL_HOME="/software/mysql-5.6.21"

exportPATH="$PATH:$MYSQL_HOME/bin"

儲存退出

. /etc/profile

 

 

啟動mysql:

[[email protected] local]# cd/usr/local/mysql5.638/support-files/

 

[[email protected] support-files]# cpmysql.server  /etc/init.d/mysql

[[email protected] support-files]#

[[email protected] ~]# /etc/init.d/mysql  start

Starting MySQL..                                          [  OK  ]

[[email protected] ~]#

登入:

[[email protected] ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.38-log MySQL Community Server (GPL)


Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


[email protected] [(none)]>