在linux安装出现的有关问题与解决方案
源码包安装的话
# ./mysql_install_db.sh
FATAL ERROR: Could not find @bindir@/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
文档是要求步骤是这样的:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/ /etc/
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/ /etc//
我的安装包中的scripts中的文件mysql_install_db是带有SH的,就进行不下去了
# ./mysql_install_db --user=mysql
-bash: ./mysql_install_db: No such file or directory
scripts # ./mysql_install_db.sh --user=mysql
FATAL ERROR: Could not find @bindir@/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
我的系统版本为:Linux syscout 2.6.17-gentoo-r7
进入解压目录
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --datadir=/var/lib/mysql
.make && make install
.cp support-files/ /etc/
./mysql_install_db --user=mysql --datadir=/var/lib/mysql;
Linux下源码编译安装MySQL
特别值得一提的是Linux Mysql有很多值得学习的地方,这里我们主要介绍Linux Mysql,包括介绍Linux Mysql安装等方面。Fedora 10下安装Linux Mysql+Apache+Php(2009-02-19 13:36:46)标签:it 分类:技术进程首先我用的各软件版本分别是:MySQL:5.1.30Apache:2.2.3Php:5.2.8
安装之前,如果安装过其他版本的Linux Mysql、Apache和Php,要先卸载。使用rpm包安装的用删除rpm包语句:[rpm -e 包名],查询包名用语句:[rpm -qa | grep 包名]。有依赖关系的包也要一次删除,这样才能成功的删除这些rpm包。
1.本次安装使用的都是源码编译安装,将Linux Mysql-5.1.复制到/usr/local/src下,然后解压安装,具体步骤如下:
#cd /usr/local/src
#tar -zxvf mysql-5.1.
#cd mysql-5.1.30
#groupadd -r mysql //创建mysql用户组
#useradd -m -r -g mysql -d /var/lib/mysql -s /bin/bash \
>-c "MySQL Server" mysql
#./configure --prefix=/usr/local/mysql \ //指定mysql安装目录
>--sysconfdir=/etc \ //指定mysql配置文件存放目录
>--localstatedir=/var/lib/mysql \//指定mysql数据库存放目录
>--enable-local-infile \ //激活load data local infile语句,使mysql支持使用该语句
>--with-charset=utf8
>--with-collation=utf8_general_ci
>--with-extra-charsets=latin1
#make //编译(需较长时间)
#make install //安装
#make clean
#make distclean
Mysql初始化数据库
#cd /usr/local/mysql
#/bin/mysql_install_db --user=mysql//初始化系统数据库
#ls /var/lib/mysql //查看存放数据库中的目录内容
3Linux Mysql.修改数据库目录所有者
#chown -R mysql:mysql /var/lib/mysql
4.复制Linux Mysql配置文件到/etc目录中,并更名为。操作命令为:
#cp /usr/local/mysql/share/mysql/ /etc/ //一般正常安装之后已经有该文件,可以不用拷贝
5.复制生成Linux Mysql服务器的自动与停止脚本
#cp /usr/local/mysql/share/mysql/ /etc///mysql
6.修改/etc///mysql文件中的基本路径:
#vi /etc///mysql
将basedir=修改为basedir=/usr/local/mysql
7.将Linux Mysql服务添加到服务器管理中,并设置自启动状态:
#chkconfig --list | grep mysql //查询当前是否有mysql服务
#chkconfig --add mysql //添加mysql服务到服务器管理中
#chkconfig --list | grep mysql //查询此时mysql服务器的启动状态
#chkconfig --level 35 mysql on //设置在3、5运行级别也自启动
8.启动Linux Mysql服务器
#service mysql start 或 /etc///mysql start
9.测试Linux Mysql服务器
#/usr/local/mysql/bin/mysqladmin version测试服务器是否已启动
#/usr/local/mysql/bin/mysqladmin pin(出现:)mysql is alive
Mysql设置root账户密码
#/usr/local/mysql/bin/mysqladmin -u root -h 主机名 -p password '新密码'由于在编译PHP源码时,会使用到部分MySQL的库文件和头文件,若服务器还需提供PHP动态网页服务,会导致找不到相应的文件,解决办法是 为目录创建一个符号连接,其实现的操作命令如下:
#ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
#ln -s /usr/local/mysql/include/mysql /usr/include/mysql
注:若正常安装后mysql命令不能使用,解决办法:在.bashrc文件中添加(alias mysql='安装目录/bin/mysql')(eg:alias mysql='/usr/local/mysql/bin/mysql')为bin文件夹下的mysql命令区一个别名或者添加环境变量,在终端输入 (export mysql="/usr/local/mysql/bin")或在/etc/profile文件中添加条目(export PATH=$PATH:/usr/local/mysql/bin)我本人安装完毕,使用service mysql start启动mysql时,出现Mysql服务启动失败信息如下:
Starting of pid-file quit without updating fi[Failed]解决办法:只要将/etc/里面的 skip federated注释掉即可。因机器和版本的种种差异,可能每个人都会出现一些问题,这些问题大家只好去Google上查了。这样,MySQL基本上就 安装完毕了,接下来我们来安装和配置Apache-2.2.3。
安装Apache-2.2.3
#cd /usr/local/src
#tar -zxvf httpd-2.2.
#cd httpd-2.2.3
#./configure --prefix=/usr/local/apache \
>--enable-so \
>--with-mpm=prefork \
>--enable-modules="setenvif rewrite deflate vhost_alias"
#make
#make install
#usr/local/apache/bin/apachectl start
设置apache自启动:
#echo "/usr/local/apache/bin/apachectl start">> /etc//在/etc//中添加
#echo "/usr/local/apache/bin/apachectl start" /usr/local/apache/bin/apachectl start
或者
将apachectl复制到/etc//下
#cp /usr/local/apache/bin/apachectl /etc///apache
在/etc///apache的第二行加入如下内容
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
#chkconfig --list | grep httpd //查看是否当前是否有apache服务
#chkconfig --add httpd
#chkconfig --level 35 httpd on //设置在3、5运行级别也自动启动
最后来安装PHP-5.2.8
#tar -zxvf php-5.2.
#cd php-5.2.8
#./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql \
>--with-apxs2=/usr/local/apache/bin/apxs
#make
#make install
#make clean
#make distclean
Apache中加载php模块:
#cp -dist /usr/local/lib/
#vim
添加如下内容:
LoadModule php5_module modules/
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
解决Cannot load /usr/local/apache/modules/的方法今天安装httpd-2.2.3 和php-5.2.8,一切顺利,最后一步重新启动apache报如下错误:(真是个好编剧,总是最后发生异常)httpd: Syntax error on line 53 of /usr/local/apache/conf/: Cannot load /usr/local/apache/modules/ into server: /usr/local/apache/modules/: cannot restore segment prot after reloc: Permission denied
解决办法:原因是Linux有一个SELinux保护模式引起的。
1关闭SELINUX的方法:
vim /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 需要重启
2不关闭SELINUX的方法:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/
# service httpd restart
# setenforce 1
附一个较全的PHP编译参数:./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-openssl --with-zlib --disable-ctype --enable-exif --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --with-gd --enable-mbstring --with-mysqli --with-mysql=/usr/local/mysql --with-pdo-mysql --enable-soap --enable-sqlite-utf8 --with-pear=/usr/local/php/pear
5.1的版本有个官方文档
/doc/refman/ ...
这里也把命令贴出来,专供懒人
# Preconfiguration setup
shell> groupadd mysql
shell> useradd -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
# Next command is optional
shell> cp support-files/ /etc/
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/ /etc//