linux 下 MySQL源码包的安装
实验环境 VMware +redhatEnterprise AS
实验目的 初步涉及源码包的安装以简单实现其功能为目的不对原理进行深层讨论
内核版本
今天尝试安装MySQL的源码包 mysqltargz
下载源码包 copy 到linux
[root@localhost ~]# cd /tmp
[root@localhost tmp]# ls
gconfdlaowu scimhelpermanagersocketroot
gconfdroot scimpanelsocket:laowu
keyringzbFJ scimpanelsocket:root
linuxqq_vbeta_i scimsocketfrontendroot
linuxqq_vbeta_itargz sealertlog
mappinglaowu sshlgCAZY
mappingroot virtualrootKezK
mysqltargz VMwareDnD
orbitroot vmwareroot
scimbridgelockfile@localhost: VMwareToolstargz
scimbridgesocket@localhost: vmwaretoolsdistrib
[root@localhost tmp]#
[root@localhost tmp]# tar zxvf mysqltargz
把源码包mysqltargz 解压到当前目录
[root@localhost tmp]# cd mysql
进入mysql目录
[root@localhost mysql]# ls
acconfigh configurein INSTALLSOURCE missing regex
acincludem COPYING isam mkinstalldirs scripts
aclocalm dbug libmysql myisam sql
bdb depcomp libmysqld myisammrg sqlbench
BUILD Docs libmysql_r mysqltest strings
ChangeLog EXCEPTIONSCLIENT ltconfig mysys supportfiles
client extra ltmainsh netware tests
configguess heap Makefileam os tools
confighin include Makefilein pstack vio
configsub innobase man readline
configure installsh merge README
[root@localhost mysql]#
INSTALLSOURCE这里面有你需要的安装命令
添加mysql用户组
[root@localhost mysql]# groupadd mysql
You have mail in /var/spool/mail/root
添加mysql用户 并指定到mysql组中
[root@localhost mysql]# useradd g mysql mysql
[root@localhost mysql]#
[root@localhost mysql]# echo /* Linuxthreads */ >> /usr/include/pthreadh
你也可以直接运行下面这条命令直接执行编译准备如果有错误试试上面得阴影部分命令
[root@localhost mysql]# /configure prefix=/usr/local/mysql
编译前的准备指定安装目录到/usr/local/mysql
试计算机性能不同时间略有差别
[root@localhost mysql]# make
编译过程
[root@localhost mysql]# make install
编译安装 稍等
[root@localhost mysql]# cp supportfiles/f /etc/f
复制mysql配置文件
[root@localhost mysql]# cd /usr/local/mysql
进入安装目录
[root@localhost mysql]# bin/mysql_install_db user=mysql
使用mysql用户 初始化数据库
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
:: /usr/local/mysql/libexec/mysqld: Shutdown Complete
To start mysqld at boot time you have to copy supportfiles/mysqlserver
to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so start the server then issue the following commands:
/usr/local/mysql/bin/mysqladmin u root password newpassword
/usr/local/mysql/bin/mysqladmin u root h localhostlocaldomain password newpassword
See the manual for more instructions
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the sqlbench directory:
cd sqlbench ; perl runalltests
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
[root@localhost mysql]#
[root@localhost mysql]# chown R root
改变当前目录的所有属主为root
R 为递归(即其下所有的子文件的属主也随之改为root)
[root@localhost mysql]# chown R mysql var
改变var的属主为mysql
[root@localhost mysql]# chgrp R mysql
改变当前目录的属组为mysql
[root@localhost mysql]#
[root@localhost mysql]# bin/mysqld_safe user=mysql &
后台启动mysql服务 &为后台启动
[]
[root@localhost mysql]# Starting mysqld daemon with databases from /usr/local/mysql/var
[root@localhost mysql]#
[root@localhost mysql]# /usr/local/mysql/bin/mysql
登陆到mysql数据库
Welcome to the MySQL monitor Commands end with ; or \g
Your MySQL connection id is to server version: log
Type help; or \h for help Type \c to clear the buffer
mysql>
mysql> show databases ;
基本的查看数据库命令
++
| Database |
++
| mysql |
| test |
++
rows in set ( sec)
mysql>
mysql> ?
查询命令
For the complete MySQL Manual online visit:
For info on technical support from MySQL developers visit:
For info on MySQL books utilities consultants etc visit:
List of all MySQL commands:
(Commands must appear first on line and end with ;)
help (\h) Display this help
? (\?) Synonym for `help
clear (\c) Clear command
connect (\r) Reconnect to the server Optional arguments are db and host
edit (\e) Edit command with $EDITOR
ego (\G) Send command to mysql server display result vertically
exit (\q) Exit mysql Same as quit
go (\g) Send command to mysql server
nopager (\n) Disable pager print to stdout
notee (\t) Dont write into outfile
pager (\P) Set PAGER [to_pager] Print the query results via PAGER
print (\p) Print current command
prompt (\R) Change your mysql prompt
quit (\q) Quit mysql
rehash (\#) Rebuild completion hash
source (\) Execute a SQL script file Takes a file name as an argument
status (\s) Get status information from the server
system (\!) Execute a system shell command
tee (\T) Set outfile [to_outfile] Append everything into given outfile
use (\u) Use another database Takes database name as argument
Connection id: (Can be used with mysqladmin kill)
mysql> quit
Bye
[root@localhost mysql]#
退出数据库