mysql5 7 21原始碼安裝

2022-03-18 19:25:46 字數 3050 閱讀 3010

mysql 5.7官方安裝文件:

mysql依賴於libaio 庫。如果這個庫沒有在本地安裝,資料目錄初始化和後續的伺服器啟動步驟將會失敗。請使用適當的軟體包管理器進行安裝。例如,在基於yum的系統上:

shell> yum search libaio 

shell> yum install libaio

shell> groupadd mysql

shell> useradd -r -g mysql -s /bin/false mysql

shell> tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz -c /usr/local

shell> cd /usr/local

shell> mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql

資料目錄:/usr/local/mysql/data 

引數檔案my.cnf:/usr/local/mysql/etc/my.cnf 

錯誤日誌log-error:/usr/local/mysql/log/mysql_error.log 

二進位制日誌log-bin:/usr/local/mysql/log/mysql_bin.log 

慢查詢日誌slow_query_log_file://usr/local/mysql/log/mysql_slow_query.log 

套接字socket檔案:/usr/local/mysql/run/mysql.sock 

pid檔案:/usr/local/mysql/run/mysql.pid 

shell> mkdir -p /usr/local/mysql/

shell> chown -r mysql:mysql /usr/local/mysql 

shell> chmod 750 /usr/local/mysql/

在/usr/local/mysql/etc/下建立my.cnf檔案,加入如下引數,其他引數根據需要配置

[client]

port = 3306

socket = /usr/local/mysql/run/mysql.sock

[mysqld]

port = 3306

socket = /usr/local/mysql/run/mysql.sock

pid_file = /usr/local/mysql/run/mysql.pid

datadir = /usr/local/mysql/data

default_storage_engine = innodb

max_allowed_packet = 128m

max_connections = 2048

open_files_limit = 65535

skip-name-resolve

lower_case_table_names=1

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci

init_connect='set names utf8mb4'

innodb_buffer_pool_size = 128m

innodb_log_file_size = 128m

innodb_file_per_table = 1

innodb_flush_log_at_trx_commit = 0

key_buffer_size = 16m

log-error = /usr/local/mysql/log/mysql_error.log

log-bin = /usr/local/mysql/log/mysql_bin.log

slow_query_log = 1

slow_query_log_file = /usr/local/mysql/log/mysql_slow_query.log

long_query_time = 5

tmp_table_size = 16m

max_heap_table_size = 16m

query_cache_type = 0

query_cache_size = 0

server-id=1

grep 'temporary password' /usr/local/mysql/log/mysql_error.log

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

9.將mysqld設定開啟自動啟動

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

chkconfig --add mysqld

10.複製配置檔案my.cnf

cp /usr/local/mysql/etc/my.cnf    /etc/my.cnf  (提示覆蓋就覆蓋)

11.啟動mysql服務

service mysql start

12.進入mysql

cd /usr/local/mysql/bin 

./ mysql -u root -p(臨時密碼)

13.修改密碼

重新設定密碼

set password for'root'@localhost=password('admin');   #對應的換成你自己的密碼即可

14、開啟遠端許可權

grant all privileges on *.* to '新使用者名稱'@'%' identified by '新密碼';

flush privileges;

15.配置環境變數

vim /etc/profile

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

source /etc/profile

window環境安裝mysql5 7 21

2.解壓到相應的目錄 此處解壓到f mysql 5.7.21 winx64 3.配置環境變數,將mysql的啟動目錄 f mysql 5.7.21 winx64 bin 新增到path中 4.在mysql目錄下 f mysql 5.7.21 winx64 建立my.ini檔案,內容如下 mysql ...

MySQL5 7 21安裝及配置

2 解壓縮到c盤 c mysql 5.7.21 winx64 3 以管理員身份執行命令列,進入目錄c mysql 5.7.21 winx64 bin 4 註冊服務 c mysql 5.7.21 winx64 bin mysqld install mysql5.7.21 5 初始化資料庫 c mysq...

mysql 5 7 21安裝和配置方法

2 新建檔案 my.ini,放置到mysql安裝目錄下,內容如下 mysql 設定mysql客戶端預設字符集 default character set utf8 mysqld 設定3306埠 port 3306 設定mysql的安裝目錄 basedir f work office mysql 5....