環境:Oracle Linux 6(64 bit)
下載mysql: http://dev.mysql.com/downloads/mysql/5.1.html 版本:5.5.36 平台:Source Code
Generic Linux (Architecture Independent), Compressed TAR Archive(mysql-5.5.36.tar.gz) 下載20.7M的這個包
接下來用cmake來安裝mysql,安裝之前先確保已安裝cmake:rpm -qa|grep cmake,並卸載舊版本的mysql
解壓tar -xzvf mysql-5.5.36.tar.gz創建安裝目錄
cd /u02 mkdir mysql mkdir mysql/data chmod -R 755 mysql-5.5.36 chmod -R 755 mysql 編譯安裝mysql 5.5.36
cd /u02/mysql-5.5.36 cmake -DCMAKE_INSTALL_PREFIX=/u02/mysql && make && make install
scripts/mysql_install_db \
--basedir=/u02/mysql \
--datadir=/u02/mysql/data \
--user=grid
cmake時的其他參數:
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/var/mysql/data修改配置文件
cp support-files/my-medium.cnf /u02/mysql/my.cnf chown -R grid:grid /u02/mysql vi /u02/mysql/my.cnf //加上以下內容
[mysqld] basedir = /u02/mysql datadir = /u02/mysql/data log-error = /u02/mysql/mysql_error.log pid-file = /u02/mysql/mysql.pid user = grid tmpdir = /tmp 啟動mysql
bin/mysqld_safe --user=grid & 將mysql加入開機啟動
cd /u02/mysql/support-files cp ./mysql.server /etc/init.d/mysqld /etc/init.d/mysqld start chmod +x /etc/init.d/mysqld vi /etc/init.d/mysqld (編輯此文件,查找並修改以下變量內容:)
basedir=/usr/local/mysql datadir=/var/mysql/data 查看服務是否已經添加到linux上
chkconfig --list mysqld chkconfig --add mysqld chkconfig --level 345 mysqld on 設置環境變量
vi /etc/profile export PATH=$PATH:/u02/mysql/bin source /etc/profile 啟動mysql服務
service mysqld start 啟動mysql
cd /u02/mysql/bin ./mysql -uroot 在shell下設置mysql密碼
mysqladmin -u root password 123456登陸mysql
mysql [-u username] [-h host] [-p[password]] [dbname] 顯示數據庫
mysql> show databases; 打開庫
mysql> use mysql; 查看表
mysql> show tables; 建庫:
create database 庫名;