以下一段時mysql官方文檔:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var //這一步沒有var...對應的數據目錄是/var/lib/mysql/
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
編譯Mysql時configure: error: No curses/termcap library found 的錯誤解決方法
apt-cache search curses | grep lib
apt-get install libncurses5-dev
redeclaration of C++ built-in type ‘bool’
安裝gcc-c++
sudo apt-get install build-essential
安裝完成後重新configure,然後make...
bin/mysqld_safe --user=mysql &這個一直沒起作用,報錯:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
到/var/lib/mysql/jonda-desktop.err中發現一錯誤:
Can't find messagefile '/usr/share/mysql/english/errmsg.sys'
修改mysqld配置文件 my.cnf,指定正確的語言文件位置
[mysqld]
language = /usr/local/src/mysql-5.1.50/sql/share/english
安裝完後給root一個密碼,不然用bin/mysql只是一般的mysql用戶登錄,只能顯示test和information_schema數據庫。
/usr/local/mysql/bin/mysqladmin -u root password '111'
/usr/local/mysql/bin/mysqladmin -u root -h jonda-desktop password 'new-password' //這句還沒用,猜測應該是隻能從本地登錄,不能遠程
/var/run/mysqld裏面放着socket和進程文件; /var/lib/mysql裏面放着數據庫數據文件,啓動、關閉數據庫日記,以及bin-log.
關閉和啓動mysql服務器:
啓動:bin/mysqld_safe --user=mysql & 或者mysqld_safe --port=port_num --defaults-file=file_name
關閉:/usr/local/mysql/bin/mysqladmin -u root -p pwd shutdown
另一種方法:把/usr/local/src/mysql-5.1.50/support-files裏面的mysql.server(這是一個shell腳本)拷貝到/etc/init.d/裏面,命名爲mysql
停止:mysql stop
啓動:mysql start...這裏遇到一問題:Couldn't find MySQL manager (/usr/bin/mysqlmanager) or server (/usr/bin/mysqld_safe),解決:在/usr/bin下面建立一個/usr/local/mysql/bin/mysqld_safe的軟連接。
到這裏幾乎一切運行正常,第一次在linux環境下成功搭建mysql環境。