Skip to content
 

Cài đặt MySQL Server 5.5.x trên Debian Squeeze

MySQL
Bài viết này sẽ hướng dẫn các bạn cài đặt MySQL Server 5.5 từ source trên Debian Squeeze.

– Cài đặt các gói thư viện và công cụ cần thiết cho việc biên dịch MySQL Server 5.5:

apt-get install libaio-dev cmake bison build-essential libncurses5-dev

– Tải source MySQL Server 5.5 tại đây và tiến hành giải nén ( ở đây tập tin source MySQL Server 5.5 của mình có tên là mysql-5.5.25a.tar.gz ) :

tar zxvf mysql-5.5.25a.tar.gz

– Cấu hình các tùy chọn cho MySQL Server (như thư mục sẽ cài đặt MySQL Server, thư mục mặc định cho việc lưu data, đường dẫn unix domain socket, vv…) thông qua CMake, danh sách đầy đủ các tùy chọn có thể tham khảo thêm tại đây:

cd mysql-5.5.25a/
cmake . -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/var/lib/mysql/ \
-DCMAKE_INSTALL_PREFIX=/opt/mysql-5.5  \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DENABLED_LOCAL_INFILE=OFF \
-DINSTALL_LAYOUT=STANDALONE -DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF -DWITH_DEBUG=OFF

– Tiến hành biên dịch MySQL Server:

make

– Tiến hành cài đặt MySQL Server:

make install

– Tạo init script và cấu hình cho MySQL chạy lúc hệ thống khởi động:

cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql 
update-rc.d  mysql defaults

– Hoàn tất việc cài đặt MySQL Server:

mkdir /var/lib/mysql
useradd -r -d /var/lib/mysql mysql
/opt/mysql-5.5/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql-5.5/ --datadir=/var/lib/mysql/

– Khởi chạy MySQL Server:

service mysql start

– Đặt mật khẩu cho tài khoản root, các bạn có thể đặt mật khẩu root bằng mysqladmin (ví dụ /opt/mysql-5.5/bin/mysqladmin -u root password ‘new-password’ ) hoặc dùng mysql_secure_installation như sau :

export PATH=$PATH:/opt/mysql-5.5/bin/
/opt/mysql-5.5/bin/mysql_secure_installation

– Dùng MySQL Client kết nối thử ? :

root@web1:/opt/src/mysql-5.5.25a# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.25a Source distribution

Copyright (c) 2000, 2011, 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.

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.5.25a   |
+-----------+
1 row in set (0.00 sec)

mysql> \q
Bye

Chúc bạn thành công! Nếu có thắc mắc gì vui lòng comment.

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Vietnam License.

2 Comments

  1. sunboy says:

    Cài làm gì vậy ku 😀