查看安装mysql的安装包
[root@litong /]# rpm -qa | grep mysql
解压mysql目录
[root@litong /]# tar -xzvf mysql-5.0.45-linux-i686.tar.gz
创建组mysql
[root@litong /]# groupadd mysql
创建用户mysql指定组mysql
[root@litong /]# useradd -g mysql mysql
创建用户mysql密码
[root@litong /]# passwd mysql
改变当前目录下所有文件和目录的所有者和所属组
[root@litong mysql]# chown -R mysql *
[root@litong mysql]# chgrp -R mysql *
安装mysql软件,mysql_install_db用于初始化服务器的存取权限
[root@litong mysql]# scripts/mysql_install_db --user=mysql
改变当前目录所有者为root
[root@litong mysql]# chown -R root .
改变data目录的所有者
[root@litong mysql]# chown -R mysql data
启动数据库,&后台启动
[root@litong mysql]# bin/mysqld_safe --user=mysql &
添加mysql环境变量
[root@litong mysql]# vi /etc/profile
export PATH=/mysql/bin:$PATH
[root@litong mysql]# source /etc/profile
启动mysql
[root@litong mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.45 MySQL Community Server (GPL)
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> create database db1;
Query OK, 1 row affected (0.00 sec)
mysql> use db1;
Database changed
mysql> create table t1 (id int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 values (1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from t1;
+------+
| id |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
mysql> exit
Bye