2011年(15)
分类: LINUX
2011-06-08 14:03:51
下载安装包()
Mysql-5.0.77.tar.gz
添加用户和组
Groupadd mysql
Useradd –g mysql mysql
解压安装包
Tar –xvzf mysql-5.077.tar.gz
配置安装选项
Cd /mysql-5.077
./configure –frefix=/usr/local/mysql
编译源代码文件
Make
安装mysql
Make install
进入/usr/local/mysql
Cd /usr/local
查看mysql目录的用户和组
Ls –ld mysql
更改mysql的目录的用户和组
Chowm –R mysql:mysql mysql
创建mysql数据库目录并初始化数据
Cd /local/bin
./mysql_install_db –user=mysql
启动mysql
Cd /usr/local/bin
Ls mysqld_safe
./mysqld_safe –help
./mysqld_safe & 后台运行
Ps –ef | grep mysql
有两个进程一个是mysql_safe是守护进程用来监控mysqld和mysqld进程
关闭mysql
./mysqladmin shutdown
查看mysql的状态
./mysqladmin status
Mysql客户端
Cd /usr/local/bin/
Ls mysql
./mysql
查看数据库
Mysql>show databases;
指定需要管理的数据库为company
Mysql>use company;
创建company数据库
Mysql>create database company;
创建employees数据表
Mysql>sreate table employees (
Employees_id varchar (10) not null.
Name varchr(10) not null.
Salary int default 0);
查看employees数据库表的表结构
Mysql >describe employees;
插入表信息
Insert into employees values (“10035”.”sam”.1000);
Insert into employees values (“10036”.”ken”.2500);
查看employees表
Select * from employees;
更新employees表
Update employees set salary=1500 where name=”sam”;
再次查看employees数据库表
Select * from employees;
删除数据库表内容
Delete from employees where name like “ken”;
Select * from employees;
删除数据库表所有内容
Delete from employees;
删除数据库表
Drop table employees;
删除数据库
Drop database company;
退出mysql客户端
Exit