免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1159 | 回复: 0
打印 上一主题 下一主题

安装mysql数据库的过程和经验分享 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-02-12 11:39 |只看该作者 |倒序浏览
整理下在Red Hat Enterprise Linux下安装mysql的过程

[paulxu@localhost ~]$ su -  \加"-"会重新初始化环境变量和执行登陆脚本,使用切换过去的用户的用户环境

Password:            \输入系统root帐户的密码



[root@localhost ~]# tar -zxf mysql-4.1.7.tar.gz   \解压缩mysql的二进制发行版本

[root@localhost ~]# cd mysql-4.1.7         \进入mysql安装目录


[root@localhost mysql-4.1.7]# ./configure
--prefix=/usr/local/mysql  \指定mysql的安装目录
--localstatedir=/mysql_data  \指定mysql的数据目录,默认Mysql的数据目录是在它的根安装目录下,可以利用这个选项来改变它
--with-mysqld-user=mysql     \出于安全及稳定性考虑,指定系统中的普通用户mysql也能启动Mysql服务器
--without-debug   /去除debug模式
--with-mysqld-ldflags=-all-static /以静态的方式编译服务器端
--with-client-ldflags=-all-static /以静态的方式编译客户端
--enable-assembler  /使用一些字符函数的汇编版本
--enable-static    
--with-low-memory   /能降低编译器的内存使用量,避免内存溢出,导致安装失败
--with-charset=gb2312
--with-extra-charsets=all
--enable-thread-safe-client
--with-pthread


[root@localhost mysql-4.1.7]# make

[root@localhost mysql-4.1.7]# make install

[root@localhost mysql-4.1.7]# groupadd mysql

[root@localhost mysql-4.1.7]# useradd mysql -g mysql -M -s /bin/false

[root@localhost mysql-4.1.7]# cp support-files/my-medium.cnf /etc/my.cnf  \复制配置文件,可以根据实际情况自己修改/etc/my.cnf里的默认值

[root@localhost mysql-4.1.7]# cp support-files/mysql.server /etc/init.d/mysqld
复制启动的mysqld文件,后面将用chkconfig命令把mysqld加入常用服务里

[root@localhost mysql-4.1.7]# chmod 700 /etc/init.d/mysqld

[root@localhost mysql-4.1.7]# cd /usr/local/mysql/

[root@localhost mysql]# chown -R root .

[root@localhost mysql]# chgrp -R mysql .

[root@localhost mysql]# chmod 755 -R .


[root@localhost bin]# ./mysql_install_db --user=mysql /后面的"--usr"一定要加,否则默认是root用户,这点比较重要

[root@localhost bin]# cd ../libexec/

[root@localhost libexec]# cp mysqld mysqld.old

[root@localhost libexec]# strip mysqld   /用strip剥离的mysqld二进制,生成的二进制速度会快4%

[root@localhost libexec]# chkconfig --add mysqld

[root@localhost libexec]# ntsysv     /检查下是否已经有了mysqld这个服务

[root@localhost libexec]# chkconfig --level 345 mysqld on

[root@localhost libexec]# service mysqld start

[root@localhost libexec]# netstat -antl    /检查是否开启了3306端口

[root@localhost libexec]# ln -s /usr/local/mysql/bin/mysql /sbin/mysql

[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin

到了这里,Mysql服务器架设完毕,在整个过程中碰到了几个问题,特此记录,防止以后自己遗忘

一.Mysql的常规日志开启是在/etc/my.cnf文件中的[mysqld]选项中指定
log="/mysql_data/mysql.log",如果不指定目录的话,默认是数据目录下的localhost.log

也可以通过运行mysqld --log --user=mysql  来开启,默认常规日志是关闭的

二.mysql_install_db是对数据目录,mysql数据库和默认的权限表进行初始化,如果是使用RPM文件来安装Mysql软件的,就不需要这步了,因为在安装过程中它会自动执行这步的,如果该脚本在执行过程中没有成功地执行完毕,它所创建出来的各种权限表就很有可能不是完成的,在你第二次执行的时候,如果该脚本发现这些权限表已经存在,就不会再去创建它们,所以在第二次执行前,必须把它们先完全删除掉
rm -rf /mysql_data

三.在执行mysql_install_db时出现错误提示
installing all prepared tables
Fill help tables
ERROR: 1153  Got a packet bigger than 'max_allowed_packet' bytes
070212  8:26:34 [ERROR] Aborting
070212  8:26:34 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete
WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!
The "HELP" command might not work properly

把max_allowed_packet增加到64M还是依旧有提示,后发现通过增加/etc/my.cnf里的net_buffer_length值解决

四.友情提示:在安装和使用Mysql的过程中多看看Mysql Reference Manual,多敲敲help会少走很多弯路.












本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/31332/showart_246400.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP