linux通過二進制包安裝mysql

 

f將mysql二進制包傳到linux服務器上/usr/local目錄下

tar -zvxf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz mysql

更改用戶用戶和組

chmod -R mysql:mysql mysql/
cd mysql/support-files
touch my_default.cnf
vim my_default.cnf

複製以下內容到文件中:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

[mysqld]



sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# 一般配置選項
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /var/run/mysqld/mysqld.sock
#socket=/tmp/mysqld.sock
character-set-server=utf8


back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M

max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8

thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6


server_id=1

innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M


innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on

[mysqldump]
quick

max_allowed_packet = 32M

[mysql]
no-auto-rehash
default-character-set=utf8
safe-updates

[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 8192

返回上層目錄中,初始化mysql

cd ../

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

如果報出權限不夠,可以在/usr/local/mysql目錄下手動新建一個data目錄 mkdir data

複製my_default.cnf和mysql.server文件到對應目錄

cp -a support-files/my_default.cnf /etc/my.cnf

cp -a support-files/mysql.server /etc/init.d/mysqld

啓動mysql

bin/mysqld_safe --user=mysql

或者將mysql的安裝路徑配置到系統路徑

vim /etc/profile

添加以下代碼

export PATH=/usr/local/mysql/bin:$PATH

source /etc/profile刷新

 

啓動mysql

service mysqld start

進入mysql客戶端

mysql -u root -p

輸入初始化時出現的密碼

若在這過程中有mysqld.sock錯誤,很大可能是my.cnf中socket配置的路徑不存在或者權限不夠,這時候手動創建該路徑並分配權限即可

mkdir /var/run/mysqld
chmod -R 777 /var/run/mysqld

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章