redhat5安装Mysql源包

[root@localhost~]#groupaddmysql//添加用户组

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

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

[root@localhosttmp]#cdmysql-5.0.95//跳转到解压目录下

[[email protected]]#./configure--prefix=/usr/local/mysql

//指定安装目录,有时可能会找不到libncursesw.so.5,此时指定

//./configure--with-named-curses-libs=/usr/lib/libncursesw.so.5--prefix=/usr/local/mysql

[[email protected]]#make//安装

[[email protected]]#makeinstall//安装

[root@localhosttmp]#cd/usr/local//查看权限并指派执行权限

[root@localhostlocal]#ls-l

drwxr-xr-x9rootroot4096Feb2520:27mysql

[root@localhostlocal]#chown-Rmysql:mysqlmysql

[root@localhostlocal]#ls-l

drwxr-xr-x9mysqlmysql4096Feb2520:27mysql

//创建用户

[root@localhostlocal]#cdmysql/bin

[root@localhostbin]#./mysql_install_db--user=mysql

//启动实例

[root@localhostbin]#./mysqld_safe&

//查看进程

[root@localhostbin]#ps-ef|grepmysql

root75923935007:06pts/100:00:00/bin/sh./mysqld_safe

mysql76097592007:06pts/100: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

root76223935007:07pts/100:00:00grepmysql

//关闭进程

[root@localhostbin]#./mysqladminshutdown

STOPPINGserverfrompidfile/usr/local/mysql/var/localhost.localdomain.pid

12022707:08:21mysqldended

[1]+Done./mysqld_safe

//进入mysql客户端

[root@localhostbin]#./mysql

//查看数据库

mysql>showdatabases;

+--------------------+

|Database|

+--------------------+

|information_schema|

|mysql|

|test|

+--------------------+

3rowsinset(0.00sec)

//创建数据库

mysql>createdatabasegavin;

QueryOK,1rowaffected(0.01sec)

//使用某个数据库实例

mysql>usegavin;

Databasechanged

//创建表

mysql>createtablestudent(

->namevarchar(10)notnull,

->gradevarchar(10)notnull,

->ageintdefault0)

->engine=MyISAM;

QueryOK,0rowsaffected(0.00sec)

//查看表信息

mysql>describestudent;

+-------+-------------+------+-----+---------+-------+

|Field|Type|Null|Key|Default|Extra|

+-------+-------------+------+-----+---------+-------+

|name|varchar(10)|NO||NULL||

|grade|varchar(10)|NO||NULL||

|age|int(11)|YES||0||

+-------+-------------+------+-----+---------+-------+

3rowsinset(0.01sec)

//删除表

mysql>droptablestudent;

//删除数据库

mysql>dropdatabasegavin;

//退出

mysql>exit

Bye

相关推荐