天天看點

Ubuntu下安裝mysql_server

Ubuntu下安裝mysql_server

(1)下載下傳

下載下傳mysql-5.0.56.tar.gz(即MySql Client Api,已經備份于qq郵箱)

tar zxvf mysql-5.0.56.tar.gz

cd mysql-5.0.56

(2)編譯

./configure --prefix=/usr/local/mysql

在編譯MYSQL時:

#./configure --prefix=/usr/local/mysql

執行後出現如下錯誤:

checking for tgetent in -ltermcap… no

checking for termcap functions library… configure: error: No curses/termcap library found

解決:安裝.sudo apt-get install libncurses5-dev,即可,再次執行上述的編譯指令。

(3)安裝

sudo make

提示g++未找到。解決:用新立得下載下傳g++.再次嘗試。

後來報錯:redeclaration of C++ built-in type ‘bool‘。解決:執行make clean,再執行make distclean,清空編譯緩存,重新編譯(./configure).

sudo make install

(4)[root@fc8 mysql-5.0.51]# make;make install

[root@fc8 ~]# cp support-files/my-medium.cnf /etc/my.cnf

[root@fc8 ~]# cd /usr/local/mysql

[root@fc8 mysql]# bin/mysql_install_db --user=mysql

[root@fc8 mysql]# chown -R root .

[root@fc8 mysql]# chown -R mysql var

[root@fc8 mysql]# chgrp -R mysql .

[root@fc8 mysql]# bin/mysqld_safe --user=mysql &

[root@fc8 mysql]# 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.0.51-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;

+--------------------+

| Database |

| information_schema | 

| mysql | 

| test | 

3 rows in set (0.00 sec)

mysql> exit

Bye

注意,以上安裝的是mysql用戶端。(用戶端隻是軟體不是服務,添加path即可,無開機啟動一說,開機啟動隻對服務而言。)

服務端請使用新立得安裝mysql-server。安裝過程會提示設定端口,設定帳号root的密碼。

啟動mysql伺服器:sudo /etc/init.d/mysql start

關閉mysql伺服器:sudo /etc/init.d/mysql stop

檢視mysql伺服器是否啟動:sudo /etc/init.d/mysql status或者netstat -a | grep mysql

由于處理init.d目錄下,mysql伺服器是開機啟動的。

    本文轉自vcdog 51CTO部落格,原文連結:http://blog.51cto.com/255361/837795,如需轉載請自行聯系原作者