mysql的安装和配置
时间:2009-07-11 来源:流星陨落
一.Mysqld的安装
1. 找到相关的安装包并解压到当前目录
cd /tmp
gunzip mysql-5.0.51-sol9-sparc-local.gz
gunzip gcc-3.4.6-sol9-sparc-local.gz
gunzip shutils-2.0.15-sol9-sparc-local.gz
gunzip ncurses-5.6-sol9-sparc-local.gz
gunzip openssl-0.9.8f-sol9-sparc-local.gz
gunzip zlib-1.1.4-sol9-sparc-local.gz
gunzip zlib-1.2.1-sol9-sparc-local.gz
gunzip zlib-1.2.2-sol9-sparc-local.gz
gunzip zlib-1.2.3-sol9-sparc-local(1).gz
2. 依次安装如上解压包
Pkgadd –d 包名称------------安装方法相同此处只以安mysql-5.0.51-sol9-sparc-local.gz为例
Pkgadd –d mysql-5.0.51-sol9-sparc-local.gz
3.进入mysql的安装目录初始化数据库
Cd /usr/local/mysql/bin/
./mysql_install_db
4.修改mysql安装目录的属组和属主
Chown -R mysql:mysql /usr/local/mysql
5.链接启动脚本文件
Cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
为了引擎随系统自动启动要链接个启动脚本:ln –s /etc/init.d/mysqld /etc/rc3.d/S96mysql
6.编辑文件/etc/my.cnf
cp /usr/local/mysql/share/mysql/my-small.cnf /etc/my.cnf
vi /etc/my.cnf
键入 "old-password" 在 [mysqld]选项
7.启动数据库引擎
/etc/init.d/mysqld start
二. Mysqld的配置
1. 连接数据库
/usr/local/mysql/bin/mysql -u root –p
Enter password:默认密码为空可直接回车
2. 创建库和表
mysql>create database Xtradb;
mysql>use Xtradb;
mysql> create table Xtra_Astatus(
AccountStatusId tinyint(4) not null,
AccountStatus varchar(10),
primary key(AccountStatusId)
);
mysql> create table Xtra_Event(
EventId tinyint(4) not null,
Event varchar(20),
primary key(EventId)
);
mysql> create table Xtra_History(
LicenseKey varchar(10),
EventDate datetime,
EventId tinyint(4),
primary key(LicenseKey,EventDate)
);
mysql> create table Xtra_Key(
LicenseKey varchar(10),
Password varchar(6),
VenderId varchar(6),
AccountStatusId tinyint(3) unsigned default 0,
ServiceLength smallint(5) unsigned default 0,
Registered datetime,
Pguid varchar(40),
Mail varchar(60),
primary key(LicenseKey))
;
mysql> create table Xtra_Vender(
VenderId varchar(6),
VenderName varchar(60),
primary key(VenderId)
);
3. 向相关的表中插入数据
insert into Xtra_Key(LicenseKey,Password,VenderId,ServiceLength) values('qubaoquan','test','CCP001','30');
insert into Xtra_Key(LicenseKey,Password,VenderId,ServiceLength) values('quxinyao','test','CCP002','30');
insert into Xtra_Key(LicenseKey,Password,VenderId,ServiceLength) values('yaoyao','test','CCP003','30');
4. 创建数据库用户
insert into mysql.user (host,user,password) values('localhost','qubaoquan',password('123456'));
flush privileges;
5. 给用户授权
grant all on Xtradb .* to qubaoquan@localhost identified by '123456';
6. 改变为旧的验证方式
在创建用户设置密码的时候格式为:
set password for qubaoquan@localhost=old_password(‘123456’)
然后从新启动数据库引擎:/etc/init.d/mysqld restart
7. 为安全起见给root用户设密码
set password for root@'localhost'=old-password('123456');