Tuesday, December 23, 2008

Install MySQL 5.0.67 on Ubuntu 8.10

Ubuntu 8.10下安装MySQL数据库是非常简单的。

下面是在Ubuntu 8.10下完成安装的MySQL,MySQL 服务器应该自动启动。您可以在终端提示符后运行以下命令来检查 MySQL 服务器是否正在运行:(见图1)

sudo netstat -tap | grep mysql

当您运行该命令时,您可以看到类似下面的行:

linuxidc@linuxidc-laptop:~$ sudo netstat -tap | grep mysql

[sudo] password for linuxidc:
tcp 0 0 localhost:mysql *:* LISTEN 7283/mysqld
linuxidc@linuxidc-laptop:~$

要在Ubuntu 8.10下安装 MySQL,我们可以在终端命令行下输入下列命令:(如图2)


sudo apt-get install mysql-server mysql-client



附过程:

linuxidc@linuxidc-laptop:~$ sudo apt-get install mysql-server mysql-client
[sudo] password for linuxidc:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会安装下列额外的软件包:
libdbd-mysql-perl libdbi-perl libnet-daemon-perl libplrpc-perl
mysql-client-5.0 mysql-server-5.0
建议安装的软件包:
dbishell mysql-doc-5.0 tinyca
下列【新】软件包将被安装:
libdbd-mysql-perl libdbi-perl libnet-daemon-perl libplrpc-perl mysql-client
mysql-client-5.0 mysql-server mysql-server-5.0
共升级了 0 个软件包,新安装了 8 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。
需要下载 35.8MB 的软件包。
解压缩后会消耗掉 109MB 的额外空间。
您希望继续执行吗?[Y/n]

当然选择Y了,在安装过程中会有软件包设置,输入root密码及再次确认。然后确定(见图3)。


如果服务器不能正常运行,您可以通过下列命令启动它:

sudo /etc/init.d/mysql restart

* Stopping MySQL database server mysqld [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Checking for corrupt, not cleanly closed and upgrade needing tables.

配置 MySQL 的管理员密码

sudo mysqladmin -u root password newpassword

配置MySQL

注意,MySQL缺省是只允许本地访问的,如果你要其他机器也能够访问的话,那么需要改变/etc/mysql/my.cnf配置文件了!

默认的MySQL安装之后根用户是没有密码的,所以首先用根用户进入:

$mysql -u root

在这里之所以用-u root是因为我现在是一般用户(firehare),如果不加-u root的话,mysql会以为是firehare在登录。注意,我在这里没有进入根用户模式,因为没必要。一般来说,对mysql中的数据库进行操作, 根本没必要进入根用户模式,只有在设置时才有这种可能。

如果你是用的root用户进入时则可以不要切换用户,直接进入第三步

进入mysql之后,最要紧的就是要设置Mysql中的root用户密码了,否则,Mysql服务无安全可言了。

mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";

注意,我这儿用的是123456做为root用户的密码

用root用户建立你所需要的数据库。我这里就以xoops为例:

mysql>CREATE DATABASE xoops;mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@localhost IDENTIFIED BY "654321";

这样就建立了一个xoops_roots的用户,它对数据库xoops有着全部权限。以后就用xoops_root来对xoops数据库进行管理,而无需要再用root用户了,而该用户的权限也只被限定在xoops数据库中。

如果你想进行远程访问或控制,那么你要做两件事:

其一:

mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@"%" IDENTIFIED BY "654321";

允许xoops_root用户可以从任意机器上登入MySQL。

测试通过了,可是不知道为什么在访问的速度上很慢,可能是UBUTN的内存只有100M的原因,哈哈!!!!



$sudo gedit /etc/mysql/my.cnf

老的版本中

>skip-networking => # skip-networking

新的版本中

>bind-address=127.0.0.1 => bind-address= 你机器的IP

这样就可以允许其他机器访问MySQL了。

DESTOP版下安装MYSQLCC

apt-get install mysqlcc

gedit /usr/share/applications/MySQLCC.desktop

Insert the following lines into the new file

将下列语句插入新文件

[Desktop Entry]

Name=MySQLCC

Comment=MySQLCC

Exec=mysqlcc

Icon=/usr/share/pixmaps/mysqlcc.xpm

Terminal=false

Type=Application

Categories=Application;System;

这样就可以使用MYSQLCC来操作数据库了。



Install MySQL 5.0.51b on Ubuntu 8.10

Problem

While install MySQL 5.0.51b for Linux on Ubuntu 8.10
when I execte configure:

sudo ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --sysconfdir=/etc

got error message:

checking for tgetent in -ltermcap... no
checking for termcap functions library... configure: error: No curses/termcap library found

Solution

need to install ncurses-5.2.tar.gz,after install, set the path in the configure parameter

or maybe the ncurses is already installed, so just add path.


add

--with-named-curses-libs=/usr/lib/libncursesw.so.5

the it looks like this:

sudo ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --sysconfdir=/etc --with-named-curses-libs=/usr/lib/libncursesw.so.5

Install Apach Tomcat 6 on Ubuntu 8.10

Before we install Tomcat we need to find out if we already have installed Java. Let’s assume that we are trying to install Tomcat we’ve already installed java, but if we aren’t sure we can check with the dpkg command like this:

dpkg –get-selections | grep sun-java

This should give us this output if we already installed java:

sun-java6-bin                                   install
sun-java6-jdk install
sun-java6-jre install

If that command has no results, we’ll want to install the latest version with this command:

sudo apt-get install sun-java6-jdk

Installation

Now we’ll download and extract Tomcat from the apache site. We should check to make sure there’s not another version and adjust accordingly.

wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.tar.gz

tar xvzf apache-tomcat-6.0.14.tar.gz

The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat.

sudo mv apache-tomcat-6.0.14 /usr/local/tomcat

Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in the .bashrc file.

The better method is editing the .bashrc file and adding the bolded line there. We’ll have to logout of the shell for the change to take effect.

vi ~/.bashrc

Add the following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

At this point we can start tomcat by just executing the startup.sh script in the tomcat/bin folder.

Automatic Starting

To make tomcat automatically start when we boot up the computer, we can add a script to make it auto-start and shutdown.

sudo vi /etc/init.d/tomcat

Now paste in the following:

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/lib/jvm/java-6-sun

case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0

We’ll need to make the script executable by running the chmod command:

sudo chmod 755 /etc/init.d/tomcat

The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.

sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Tomcat should now be fully installed and operational. Cheers!

Install Java 6 on Ubuntu 8.10

There are several ways of installing Java on the Ubuntu operating system. One of the easiest ways is to make use of apt-get command in Ubuntu.

Setup Repository

The apt-get command makes use of a source configuration file, which contains a list of the repositories the package manager should query to retrieve the correct package. The source configuration file is known as sources.list and is situated in the /etc/apt/sources.list location. The following command can be used to edit the source file to ensure the multiverse repository is included.

Code:


sudo gedit /etc/apt/sources.list

Ensure that the following two sources are added to the configuration file:


deb http://za.archive.ubuntu.com/ubuntu/ intrepid main restricted

deb http://za.archive.ubuntu.com/ubuntu/ intrepid multiverse


After the configuration file is updated, the package repository needs to updated with the following command:

Code:


sudo apt-get update


Install Java Package

After the package repository was successfully updated, the Sun Java packages can be installed on the Ubuntu system. The Sun Java packages consist of Java 5 and Java 6 packages. Depending on the version that is required, the list of packages specified below can be installed.

Java 5
The Java 5 packages available is listed as follows:

  • sun-java5-bin
  • sun-java5-fonts
  • sun-java5-plugin
  • sun-java5-demo
  • sun-java5-jdk
  • sun-java5-source
  • sun-java5-doc
  • sun-java5-jre
  • sun-java5-src

Java 6
The Java 6 packages available is listed as follows:

  • sun-java6-bin
  • sun-java6-javadb
  • sun-java6-plugin
  • sun-java6-demo
  • sun-java6-jdk
  • sun-java6-source
  • sun-java6-doc
  • sun-java6-jre
  • sun-java6-src
  • sun-java6-fonts
  • sun-java6-jre-headless

To install Java version 6, the following command needs to be executed:

Code:


sudo apt-get install sun-java6-jre sun-java6-jdk sun-java6-plugin


Verify Java Installation

To verify that the correct version of java is installed the following command can be used:

Code:


java -version

This command will print the current version of java that is active. Should there be more than one version of Java be installed on the operating system, the following command can be used to list the available java versions:

Code:


update-java-alternatives -l

This command list all the available Java runtime environments on the Ubuntu system. To change from one version to another, the following command can be used:

Code:

sudo update-java-alternatices -s



Testing Java Runtime Environment

You’ll want to confirm that your system is configured properly for Sun’s JRE. This is a two-step process.

First, check that the JRE is properly installed by running the following command from a terminal.

java -version

You should get similar output

java version “1.6.0″
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
Testing Java Plugin for Firefox

open Firefox and typing about:plugins in the address bar and check for java plugin