安裝mysql-5.0.45.tar.gz(該軟件包下載地址:http://www.filewatcher.com/m/mysql-5.0.45.tar.gz.24433261-0.html)html
# groupadd mysql #添加mysql組mysql
# useradd -g mysql mysql #添加mysql用戶,且加入mysql組sql
--------------------編譯過程----------------------------------數據庫
# tar zxvf mysql-5.0.45.tar.gz #解壓後在當前目錄下ls下,會出現mysql-5.0.45目錄centos
# cd mysql-5.0.45 #進入解壓後的mysql目錄服務器
# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=latin1ide
#--prefix=/usrlocal/mysql 是制定mysql安裝的目錄ui
#--with-charset=utf8 --with-collation=utf8_general_ci 是設置mysql默認字符集爲utf8 es5
#--with-extra-charsets=latin1 設定服務器須要支持的字符集spa
在./configure過程當中若是出現error:
checking for termcap functions library... configure: error: No curses/termcap library found
緣由:缺乏ncurses安裝包
redhat/centos系列
# yum list|grep ncurses #查看系統是否安裝了ncurses
# yum -y install ncurses-devel #個人系統中缺乏ncurses-devel,因此只要安裝該插件就好了。
Ubuntu或者Debian系列
# apt-cache search ncurses #檢查系統中ncurses
# apt-get install libncurses5-dev #安裝ncurses-devel插件
此插件安裝完成後,再次:
# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=latin1 就會成功configure了
# make && make install 開始安裝,安裝時間較長,能夠喝口茶。。。
---------------順利安裝完成--------------------------------------
# cp support-files/my-medium.cnf /etc/my.cnf #從mysql-5.0.45目錄中複製配置文件到/etc目錄中並更名爲my.cnf
# vi /etc/my.cnf #將log-bin=mysql-bin註釋掉
log-bin=mysql-bin是mysql的日誌功能,裝mysql,運行一段時間後,在mysql目錄下出現一堆相似mysql-bin.000***,從mysql-bin.000001開始一直排列下來,並且佔用了大量硬盤空間,高達幾十個G。假如你不想要這些日誌就註釋掉。
------------------初步配置mysql----------------------------------
# cd /usr/local/mysql #進入mysql的安裝目錄下
# bin/mysql_install_db --user=mysql #初始化mysql
# chown -R root . #更改當前目錄擁有者爲root。注意root後面還有個「.」意思爲當前目錄
# chown -R mysql /usr/local/mysql #改變目錄所屬爲mysql
# bin/mysql_safe --user=mysql & #在後臺啓動mysql
# bin/mysqladmin -uroot password 123456 #在mysql首次正常啓動狀況下,更改root用戶登陸密碼
# bin/mysql -uroot -p #輸入此命令後,按回車會顯示讓你輸入root密碼
mysql> show databases; #show一下你全部的數據庫。
mysql> quit; #退出mysql
-------------------把mysql加入到系統服務中------------------------
# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
這樣就能夠經過/etc/init.d/mysqld start|stop|restart來重啓mysqll
或者service mysqld start|stop|restart|status 重啓mysql或查看mysql服務狀態了
------------------ 配置mysql環境變量------------------------------
# echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile
這樣就能夠直接mysql -uroot -p123456來使用mysql了,而不用切換到mysql安裝目錄來使用mysql了
-------------------給root用戶開啓遠程訪問權限---------------------
# mysql -uroot -p #進入mysql
mysql> grant all on *.* to root@'%' identified by '123456';
#grant 權限 on 數據庫名.表名 to 用戶@登陸主機 identified by "用戶密碼"
最後默認的數據庫目錄是 /usr/local/mysql/var
這樣mysql簡單安裝就完成了,具體深刻能夠自行在研究下。。。。。。