ubuntu下安裝mysql(二進制)到自定義目錄 一,安裝 1, 下載 mysql二進制文件: http://dev.mysql.com/downloads/mysql/ 頁面,選擇linux generic ,然後選擇最後一個 “Linux - Generic (glibc 2.5) (x86, 32-bit), Compressed TAR Archive” 進行下載 (32或者64根據是實際情況) 2, 切換到root 用戶 3, 先創建一個group和一個屬於這個組的user www.2cto.com shell> groupadd group1 shell> useradd -r -g group1 user1 3, 解壓下載的二進制包, 到自己要放的位置, 如home/user/mysql 4, cd home/user/mysql 5, 賦予操作權限: chown -R user1 . chgrp -R group1 . 6, scripts/mysql_install_db --user=user1 為user1安裝數據庫 (需要libaio包,使用新德裡幫忙下一下) 7, 賦權限: chown -R root . chgrp -R group1 . chown -R root . chown -R user1 data 8,啟動mysql後台服務: bin/mysqld_safe --user=user1 & 如果沒有報錯,那麼就是服務器的啟動成功。 測試一下: 新開一個terminal, cd home/user/mysql/bin ./mysqladmin version 正確的話 就會顯示版本信息之類的 並且沒有其他錯誤報出。 二,增加安全性 cd home/user/mysql bin/mysql_secure_installation 然後具體步驟的一些 信息如下: Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! 三,便利設置 www.2cto.com 1,將mysql的路徑加到環境變量中去: sudo gedit /etc/profile 然後加入: 1, export MYSQL_HOME=home/user/mysql; 2,在PATH=XX後面加入 :$MYSQL_HOME/bin