日期:2014-05-16  浏览次数:20736 次

redhat5安装Mysql源包
[root@localhost ~]# groupadd mysql  //添加用户组

[root@localhost ~]# useradd -g mysql mysql  //添加用户并指派用户组

[root@localhost tmp]# tar -xzvf mysql-5.0.95 //解压mysql-5.0.95.tar.gz安装源文件包

[root@localhost tmp]# cd mysql-5.0.95  //跳转到解压目录下

[root@localhost mysql-5.0.95]# ./configure --prefix=/usr/local/mysql
//  指定安装目录,有时可能会找不到 libncursesw.so.5,此时指定
//   ./configure --with-named-curses-libs=/usr/lib/libncursesw.so.5 --prefix=/usr/local/mysql

[root@localhost mysql-5.0.95]# make //安装

[root@localhost mysql-5.0.95]# make install //安装

[root@localhost tmp]# cd /usr/local //查看权限并指派执行权限
[root@localhost local]# ls -l
drwxr-xr-x 9 root root 4096 Feb 25 20:27 mysql
[root@localhost local]# chown -R mysql:mysql mysql
[root@localhost local]# ls -l
drwxr-xr-x 9 mysql mysql 4096 Feb 25 20:27 mysql

// 创建用户
[root@localhost local]# cd mysql/bin
[root@localhost bin]# ./mysql_install_db --user=mysql
// 启动实例
[root@localhost bin]# ./mysqld_safe &
// 查看进程
[root@localhost bin]# ps -ef|grep mysql
root      7592  3935  0 07:06 pts/1    00:00:00 /bin/sh ./mysqld_safe
mysql     7609  7592  0 07:06 pts/1    00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --pid-file=/usr/local/mysql/var/localhost.localdomain.pid --skip-external-locking
root      7622  3935  0 07:07 pts/1    00:00:00 grep mysql
//关闭进程
[root@localhost bin]# ./mysqladmin shutdown
STOPPING server from pid file /usr/local/mysql/var/localhost.localdomain.pid
120227 07:08:21  mysqld ended

[1]+  Done                    ./mysqld_safe
//进入mysql客户端
[root@localhost bin]# ./mysql
//查看数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)
//创建数据库
mysql> create database gavin;
Query OK, 1 row affected (0.01 sec)
//使用某个数据库实例
mysql> use gavin;
Database changed
//创建表
mysql>  create table student(
    -> name varchar(10) not null,
    -> grade varchar(10) not null,
    -> age int default 0)                                                      
    -> engine=MyISAM;
Query OK, 0 rows affected (0.00 sec)
//查看表信息
mysql> describe student;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name  | varchar(10) | NO   |     | NULL    |       |
| grade | varchar(10) | NO   |     | NULL    |       |
| age   | int(11)     | YES  |     | 0   &