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服务器是开机启动的。