Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> MySQL

Cài đặt MySQL trên Unix/Linux dùng Generic Binaries

Oracle cung cấp bộ phân phối binary MySQL. Bao gồm generic binary distribution dạng file tar nén (.tar.xz) cho nhiều nền tảng, và binary dạng package dành riêng cho nền tảng cụ thể.

Tên file binary distribution nén tar: mysql-VERSION-OS.tar.xz (VERSION là số, OS chỉ hệ điều hành).

Để cài binary distribution tar nén, giải nén vào vị trí do người dùng chọn. Phiên bản debug của mysqld có sẵn dạng mysqld-debug.

Nếu dùng bản debug riêng để compile MySQL từ source distribution, dùng tùy chọn cấu hình phù hợp.

Để cài và dùng MySQL binary distribution, dùng chuỗi lệnh sau:

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar xvf /path/to/mysql-VERSION-OS.tar.xz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
# Lệnh dưới tùy chọn
shell> cp support-files/mysql.server /etc/init.d/mysql.server

Cài đặt MySQL trên Unix/Linux dùng Generic Binaries

Giả định user có quyền root (admin).

Cài đặt MySQL trên Unix/Linux dùng Generic Binaries

Thư mục mysql-files cung cấp vị trí dễ dàng cho biến hệ thống secure_file_priv, giới hạn import/export chỉ trong thư mục cụ thể. Xem Section 5.1.8 "Server System Variables".

Tóm tắt các bước

Tạo user và group mysql:

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

Lấy và giải nén phân phối:

shell> cd /usr/local

Giải nén phân phối, tạo thư mục cài đặt. tar có thể giải nén và unpack nếu hỗ trợ tùy chọn 'z':

shell> tar xvf /path/to/mysql-VERSION-OS.tar.xz

Lệnh tar tạo thư mục mysql-VERSION-OS.

Thay tar bằng lệnh dưới để giải nén và extract:

shell> xz -dc /path/to/mysql-VERSION-OS.tar.xz | tar x

Tạo symbolic link tới thư mục cài đặt do tar tạo:

shell> ln -s full-path-to-mysql-VERSION-OS mysql

Lệnh ln tạo symbolic link. Cho phép tham khảo đường dẫn dễ dàng hơn như /usr/local/mysql. Thêm /usr/local/mysql/bin vào PATH:

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