mysql安装笔记
cloud/2003.10.10
mail:flashc@21cn.com
欢迎转载,转载请保留上述信息,谢谢
学习了很长时间的linux,有必要做一下整理笔记了,以下是mysql的安装笔记,和常见的一些使用方法。
因我喜欢调试优化系统,所以在编译安装时使用了一些选项增加编程后程序的执行效率,有些可能我理解有错,希望大家指出.
●安装mysql
# tar zxvf mysql-4.0.14.tar.gz -C /setup
# cd /setup/mysql-4.0.14
# groupadd mysql
# useradd mysql -g mysql -M -s /bin/false
# ./configure --prefix=/web/mysql \ 指定安装目录
--without-debug \去除debug模式
--with-extra-charsets=gb2312 \添加gb2312中文字符支持
--enable-assembler \使用一些字符函数的汇编版本
--without-isam \去掉isam表类型支持 现在很少用了 isam表是一种依赖平台的表
--without-innodb \去掉innodb表支持 innodb是一种支持事务处理的表,适合企业级应用
--with-pthread \强制使用pthread库(posix线程库)
--enable-thread-safe-client \以线程方式编译客户端
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \以纯静态方式编译服务端和客户端 --with-raid \激活raid支持
# make
# make install
# scripts/mysql_install_db \生成mysql用户数据库和表文件
# cp support-files/my-medium.cnf /etc/my.cnf \copy配置文件,有large,medium,small三个环境下的,根据机器性能选择,如果负荷比较大,可修改里面的一些变量的内存使用值
# cp support-files/mysql.server /etc/init.d/mysqld \copy启动的mysqld文件
# chmod 700 /etc/init.d/mysqld
# cd /web
# chmod 750 mysql -R
# chgrp mysql mysql -R
# chown mysql mysql/var -R
# cd /web/mysql/libexec
# cp mysqld mysqld.old
# strip mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
# service mysqld start
# netstat -atln
看看有没有3306的端口打开,如果mysqld不能启动,看看/web/mysql/var下的出错日志,一般都是目录权限没有设置好的问题
# ln -s /web/mysql/bin/mysql /sbin/mysql
# ln -s /web/mysql/bin/mysqladmin /sbin/mysqladmin
# mysqladmin -uroot password "youpassword" #设置root帐户的密码
# mysql -uroot -p
# 输入你设置的密码
mysql>;use mysql;
mysql>;delete from user where password=""; #删除用于本机匿名连接的空密码帐号
mysql>;flush privileges;
mysql>;quit
●安装DBI和DBD for mysql 用于提供perl访问mysql数据库的接口规范,请确认你已经安装了perl,一般默认系统都装上了
# cd /setup
# tar zxvf DBD-mysql-2.9002.tar.gz -C /setup
# tar zxvf DBI-1.38.tar.gz -C /setup
# cd DBI-1.38
# perl Makefile.PL
# make
# make test
# make install
因为有的perl程序中perl的路径是/usr/local/bin/perl,而红帽系统默认是/usr/bin/perl,所以最好做一个连接,保证兼容性
# ln -s /usr/bin/perl /usr/local/bin/perl
# cd ../DBD-mysql-2.9002
生成安装配置文件需要在perl Makefile.PL后添加一些参数,比较麻烦,我们可以通过添加一个到/web/mysql/bin/mysql_config这个程序的连接解决问题
系统会自动寻找这个命令生成安装所需要的数据库参数
# ln -s /web/mysql/bin/mysql_config /sbin/mysql_config
# perl Makefile.PL
# make
# make instll (这里make test我总是运行一半就出错,但是安装后是可以运行mysql目录下的测试脚本,不知道3.x的mysql如何)
现在你可以运行测试脚本了,不过速度很慢,挂在后台好了
# perl /web/mysql/sql-bench/run-all-tests --user=root --password="youpassword"
附:
●mysql常见的一些有用的选项和命令
mysqld -----开启日志支持
--log
--log-update
--log-long-formart
●mysql
grant all on database.* to user identified by "password" 新建一user用户,赋予其database数据库的所有权限
revoke all on database from user 移除user用户在database数据库上的所有权限
mysql -uroot -p --one-database databasename < file.sql 从file.sql文件导入sql语句到databasename这个数据库里
●mysqladmin
mysqladmin flush-logs 命令mysqld重新打开一个新的日志文件,就是清空老日志文件,相当于轮回了
●mysqldump
--add-drop-table 导出sql语句时添加droptable if exists语句
--quick 快速导出
--opt 优化选项(推荐)
●myisamchk
检查表选项
--extend-check 扩展检查
--medium-check 速度比较折中的一个检查选项
修复表选项
--recover 修复表文件
--safe-recover 安全修复表文件,比--recover要慢
修饰修复表项
--force 强制清除上次的临时文件
--quick 只根据素引文件的内容进行修复
●mysql的管理
可以使用phpmyadmin(需要php的环境支持)和mysqlcc(linux图形界面支持,WINDOWS系统支持)
geniusdao 回复于:2003-10-15 21:54:31
楼主,我按照你的方法去做,可是解压以后执行./configure --prefix=/web/mysql 后,往下在接着执行make 怎么执行不了呢?提示没有makefile found 之类的话。也没有install文件生成阿。请解释一下好吗?急等!
cloudxx 回复于:2003-10-16 00:06:01
那肯顶是你的configure没有完成 可能出错了吧 注意看下输出
Trotter 回复于:2003-10-16 08:40:11
不错,加为精华,支持一下,继续努力。
geniusdao 回复于:2003-10-16 10:14:18
你的意思是说,只有configure正确后才能出现install这个文件吗?我觉得我的configure挺正确的,但是我运行的时候它的提示好象说,这个版本是一个已经config后的,可以直接使用。我不知道你运行configure后提示的是什么话。是不是我下载的版本有问题啊?我是在mysql的网站上linux页面第一行的那个版本mysql-standard-4.0.15-pc-linux-i686.tar.gz。我不知道是不是你所说的那个版本。
cloudxx 回复于:2003-10-16 10:26:42
你下的不是源代码版本的吧?
cloudxx 回复于:2003-10-16 10:26:57
你下的不是源代码版本的吧?看写README 和INSTALL文当吧
geniusdao 回复于:2003-10-16 13:27:20
哥们,能不能给我一个源代码下载的连接,现在我很迷茫,麻烦,谢了!
gunguymadman007 回复于:2003-10-16 14:09:34
ding
geniusdao 回复于:2003-10-16 17:49:20
别光顶阿,有知道的朋友,告诉一下阿
cloudxx 回复于:2003-10-16 19:26:04
http://www.mysql.com/downloads/mysql-4.0.html
Source downloads
Compiler Advisory: Several users have reported random crashes and table corruptions when using MySQL binaries compiled with gcc 2.96 on the x86 Linux platform. We suggest that you use gcc 2.95 or gcc 2.91 to compile your own binaries. It should also be safe to use gcc 3.2.
For maximum stability and performance, we recommend that you use the binaries we provide.
Tarball (tar.gz) 4.0.15a 12.2M Download
geniusdao 回复于:2003-10-16 20:19:24
thanks
jakechen 回复于:2003-10-16 22:56:01
引用:原帖由 "geniusdao"]楼主,我按照你的方法去做,可是解压以后执行./configure --prefix=/web/mysql 后,往下在接着执行make 怎么执行不了呢?提示没有makefile found 之类的话。也没有install文件生成阿。请解释一下好吗?急等! 发表:
老大,你下的是二进制包,编译好了的,直接接压缩到相关目录就可以了,
顺便谢谢楼上的教学。
ss0616 回复于:2003-10-17 10:30:51
引用:原帖由 "cloudxx" 发表: http://www.mysql.com/downloads/mysql-4.0.html
Source downloads
Compiler Advisory: Several users have reported random crashes and table corruptions when using MySQL binaries compiled with gcc 2.96 ..........
不要笑我,我刚开始学这个。
问一下,Linux (Alpha)分三种下载:Standard,Max,Debug。它们有什么区别吗?
cloudxx 回复于:2003-10-17 11:14:20
看字面意思吧 标准,最大,除错 三种编译包
ss0616 回复于:2003-10-17 11:37:08
引用:原帖由 "cloudxx"]看字面意思吧 标准,最大,除错 三种编译包 发表:
三个安装好了没什么区别吧??最后一个包是其它两个包的一倍。
geniusdao 回复于:2003-10-18 18:14:27
引用:原帖由 "cloudxx"]你下的不是源代码版本的吧? 发表:
我如果下的不是源代码的版本,那改如何安装和设置呢?我已经安装了1个礼拜了。使用你的方法安装源代码也不好用,总是说找不到/tmp/mysql。stock。但是已经又这个文件了,不过我看字节是0。我看还是用直接安装的那个文件安装吧(mysql-standard-4.0.15-pc-linux-i686.tar.gz),楼主知道怎么安装和设置吗?
suncqq 回复于:2003-10-19 19:54:49
老大,俺想请教一个问题!!!
俺用的mysql直接解压就可以用了,不用编译的,版本是:mysql-4.0.13.tar.gz
俺是创建mysql用户,启动数据库的时候提示如下错误:
再执行这个语句:/usr/local/mysql/bin/mysqld_safe --user=mysql &
显示如下:
[1] 24154
[root@localhost bin]# The file /usr/local/mysql/libexec/mysqld doesn't exist or is not
executable
Please do a cd to the mysql installation directory and restart
this script from there as follows:
./bin/mysqld_safe.
查看错误日志提示如下:
/usr/local/mysql/bin/mysqld: ERROR: unknown option '--log-bin # required for replication'
031012 10:00:04 mysqld ended
到底是什么原因呢?
cloudxx 回复于:2003-10-19 20:00:04
目录权限呢?是否建了mysql这个用户呢?看日志你好象是加了错误的选项了 可是你的操作没有 怪呢
不行就编译一个吧 我的操作基本是一步一步来的 照着来一定不会有错
suncqq 回复于:2003-10-19 20:08:48
引用:原帖由 "cloudxx" 发表: 目录权限呢?是否建了mysql这个用户呢?看日志你好象是加了错误的选项了 可是你的操作没有 怪呢
不行就编译一个吧 我的操作基本是一步一步来的 照着来一定不会有错
俺是这样安装和启动mysql数据库的!!!
groupadd mysql
useradd -g mysql mysql
cd /usr/local
gunzip < /usr/local/mysql-standard-4.1.0-alpha-pc-linux-i686.tar.gz | tar xvf -
ln -s /usr/local/mysql-standard-4.1.0-alpha-pc-linux-i686 mysql
cd mysql
scripts/mysql_install_db
chown -R root .
chown -R mysql data
chgrp -R mysql .
运行MySQL:
./bin/mysqld_safe --user=mysql &
有问题么?
zenisys 回复于:2003-10-20 23:50:11
多写
冰魂 回复于:2003-10-22 12:03:49
我的MYSQL无法启动
查看日志如下:
031022 11:47:16 mysqld started
031022 11:47:16 Fatal error: Can't open privilege tables: Table 'mysql.host' doesn't exist
031022 11:47:16 Aborting
mysql.host表不存在。那就是在创建表的时候出了问题。
这是我建表的记录:
[root@localhost mysql-4.0.15a]# scripts/mysql_install_db
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.
key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=0
max_connections=100
threads_connected=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 80383
K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
thd=0x8290d48
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0xbf5fea68, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x808aa06
0x8153b0c
0x816a396
0x809ad75
0x809db1f
0x809ab94
0x8095484
0x814ef61
0x818aafa
scripts/mysql_install_db: line 1: 5141 Segmentation fault /usr/local/mysql/libexec/mysqld --bootstrap --skip-grant-tables --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --skip-innodb --skip-bdb
Installation of grant tables failed!
Examine the logs in /usr/local/mysql/var for more information.
You can also try to start the mysqld daemon with:
/usr/local/mysql/libexec/mysqld --skip-grant &
You can use the command line tool
/usr/local/mysql/bin/mysql to connect to the mysql
database and look at the grant tables:
shell>; /usr/local/mysql/bin/mysql -u root mysql
mysql>; show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /usr/local/mysql/var that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/local/mysql/bin/mysqlbug script!
哪位大哥帮我看看啊。
冰魂 回复于:2003-10-22 13:43:48
解决了,configure的时候我只加了--prefix的参数。
不过我不清楚为什么要加别的参数,
ss0616 回复于:2003-10-25 08:33:41
我的也OK了~~谢谢
wjger 回复于:2003-10-31 09:13:18
我在redhat9下严格按照老大的步骤安装,但在执行命令时scripts/mysql_install_db不能创建表,不知为什么?
cloudxx 回复于:2003-10-31 13:03:00
出错信息呢 ?
蓝色虫 回复于:2003-10-31 15:12:33
uping...
jjlovelml 回复于:2006-02-13 19:47:03
感谢搂组的好文章
donee 回复于:2006-03-07 12:14:11
是不是没有装一些开发软件啊,如gcc.........
jianghao0726 回复于:2006-03-10 17:03:59
你的是以经编译好的了,建完用户,就可以用了
fuxinrong 回复于:2006-03-11 14:29:52
我按你写的步骤去安装,在添加用户组及用户时出问题了!这是怎么回事?
[fuxinrong@localhost fuxinrong]$ su root
Password:
[root@localhost fuxinrong]# groupadd mysql
bash: groupadd: command not found
[root@localhost fuxinrong]#
楼主帮帮我啊!!!
fuxinrong 回复于:2006-03-11 14:32:36
[fuxinrong@localhost fuxinrong]$ su root
Password:
[root@localhost fuxinrong]# groupadd mysql
bash: groupadd: command not found
[root@localhost fuxinrong]#
我的groupadd命令怎么用不了????请各位高手帮忙!!!!!
benkernel 回复于:2006-04-17 17:42:53
不错,支持一下
xxjoyjn 回复于:2006-04-17 20:38:50
支持
windychan 回复于:2006-04-18 12:52:40
这种转载别人多年前的文也要加精的话,CU中的精华真的需要加问号了!
cloudxx 回复于:2006-06-16 16:34:47
引用:原帖由 windychan 于 2006-4-18 12:52 发表
这种转载别人多年前的文也要加精的话,CU中的精华真的需要加问号了!
不知你的转载从何说起?我三年前写的文章 自己实际编译查资料做的,你偏偏说要是转载?那请你找下原出处?
xxjoyjn 回复于:2006-06-17 10:08:19
你下载的是二进制文件文件,可以直接解压就完成了安装了,要是下载原代码的就需要
configure
make
make install
promise2005 回复于:2006-07-15 00:01:26
安装步骤安装mysql5.0.22版的源码包,一直按步骤操作都没有出错,但就是无法启动,去到# service mysqld start
xxjoyjn 回复于:2006-07-15 17:13:29
敲入./configure命令后就不要不管事了,configure后,在输出结尾总有configure的结果信息
肯定是出现错误了,只是你自己没有注意而已,configure不成功,当然就无法make
xxjoyjn 回复于:2006-07-15 17:15:40
引用:原帖由 fuxinrong 于 2006-3-11 14:32 发表
[fuxinrong@localhost fuxinrong]$ su root
Password:
[root@localhost fuxinrong]# groupadd mysql
bash: groupadd: command not found
[root@localhost fuxinrong]#
我的groupadd命令怎么用不了????请各位 ...
whereis groupadd
audiotech 回复于:2006-07-17 16:49:03
好像2个版本都是不一样的
xuxingyu 回复于:2007-01-11 17:57:29
好东西,正在学:oops:
xuxingyu 回复于:2007-01-11 17:58:40
mysql 这么大的网站,打开网页好慢,是线路问题:em14:
loveb 回复于:2007-01-12 15:46:06
这几天让MYSQL给我搞的。要是早看到这个不就OK'了。
huangsm 回复于:2007-01-30 11:40:17
mark
chenyufan 回复于:2007-02-06 22:40:41
引用:原帖由 ss0616 于 2003-10-17 10:30 发表
不要笑我,我刚开始学这个。
问一下,Linux (Alpha)分三种下载:Standard,Max,Debug。它们有什么区别吗?
MySQL具有很多不同的形式,至少有四种不同的版本:MySQL standard、MySQL Max、MySQL Pro以及MySQL Classic。
除了许可证以外,MySQL Standard 和 MySQL Pro是完全一样的。
MySQL Standard注册在GNU Public License (GPL),而MySQL Pro 是MySQL Standard的商业注册版本。
MySQL Max包括一些尖端的和实验性的功能,这些功能不推荐在生产中使用。
MySQL Class仅在取得商业许可证后才能使用,并缺少很多重要功能。这类应用程序需要支持像事务和参照完整性(也就是外键)约束这样的关键功能。
chenyufan 回复于:2007-02-06 22:42:17
当你在www.mysql.com下载MySQL的时候,会发现有binary/rpm/source三种包。binary distribution是由mysql官方优化编译好的,不需要make。
holycn 回复于:2007-02-08 11:24:58
我安装完mysql后,telnet 127.0.0.1 3306
出现 NHost 'localhost.localdomain' is not allowed to connect to this MySQL serverConnection closed by foreign host
而且telnet本地另外几个ip都报这个错
怎么会这样呢,安装过程没有报错,mysql启动正常
1tsky 回复于:2007-02-10 16:33:46
4.1的WIN版,一设置密码就不能用PHPMYADMIN管理了,是什么原因呀!
jacky_hui 回复于:2007-02-11 18:38:12
帮顶一下.
jiang89f 回复于:2007-04-15 21:36:51
我好像没有用到这么多,楼主研究东西很细啊,那个apache也是
chenyufan 回复于:2007-05-23 13:55:51
引用:原帖由 1tsky 于 2007-2-10 16:33 发表
4.1的WIN版,一设置密码就不能用PHPMYADMIN管理了,是什么原因呀!
SET PASSWORD FOR 'username'@'localhost' = OLD_PASSWORD('yourpassword');
|