在linux安装出现的问题与解决方案

21 篇文章 0 订阅
16 篇文章 0 订阅

 

FATAL ERROR: Could not find ./bin/my_print_defaults 解决方法
网上很多方法都是:/usr/local/mysql/scripts/mysql_install_db --user=mysql
但是很有可能报错,找不到bin目录中的my_print_defaults
错误信息:
FATALERROR:Couldnotfind./bin/my_print_defaults
If you are using a binary release, you must run this script from
within the directory the archive extracted into. If you compiled
MySQL yourself you must run 'make install' first.
       或
[root@bogon scripts]# /usr/local/mysql/scripts/mysql_install_db --user=mysql&
[1] 16874
[root@bogon scripts]#
FATAL ERROR: Could not find ./bin/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.
 
解决方法:
 [root@bogon scripts]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &(& 后台执行)
 


源码包安装的话
# ./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/mysql-VERSION-OS.tar.gz
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/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

我的安装包中的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/my-medium.cnf /etc/my.cnf
./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.30.tar.gz复制到/usr/local/src下,然后解压安装,具体步骤如下:


#cd /usr/local/src 
#tar -zxvf mysql-5.1.30.tar.gz 
#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 
2.Linux 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目录中,并更名为my.cnf。操作命令为:


#cp /usr/local/mysql/share/mysql/my-large.cnf /etc/my.cnf   //一般正常安装之后已经有该文件,可以不用拷贝
5.复制生成Linux Mysql服务器的自动与停止脚本


#cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysql
6.修改/etc/rc.d/init.d/mysql文件中的基本路径:

#vi /etc/rc.d/init.d/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/rc.d/init.d/mysql start
9.测试Linux Mysql服务器


#/usr/local/mysql/bin/mysqladmin version测试服务器是否已启动 
#/usr/local/mysql/bin/mysqladmin pin(出现:)mysql is alive
10.Linux 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 MySQL.Manager of pid-file quit without updating fi[Failed]解决办法:只要将/etc/my.cnf里面的 skip federated注释掉即可。因机器和版本的种种差异,可能每个人都会出现一些问题,这些问题大家只好去Google上查了。这样,MySQL基本上就 安装完毕了,接下来我们来安装和配置Apache-2.2.3。

安装Apache-2.2.3


#cd /usr/local/src 
#tar -zxvf httpd-2.2.3.tar.gz 
#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/rc.d/rc.local在/etc/rc.d/rc.local中添加 
#echo "/usr/local/apache/bin/apachectl start" /usr/local/apache/bin/apachectl start

或者
将apachectl复制到/etc/rc.d/init.d下
#cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache
在/etc/rc.d/init.d/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.8.tar.gz 
#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 php.ini-dist /usr/local/lib/php.ini
#vim httpd.conf

添加如下内容:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

解决Cannot load /usr/local/apache/modules/libphp5.so的方法今天安装httpd-2.2.3 和php-5.2.8,一切顺利,最后一步重新启动apache报如下错误:(真是个好编剧,总是最后发生异常)httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: 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/libphp5.so
# 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的版本有个官方文档

http://dev.mysql.com/doc/refman/ ... e-distribution.html


这里也把命令贴出来,专供懒人

    # Preconfiguration setup
    shell> groupadd mysql
    shell> useradd -g mysql mysql
    # Beginning of source-build specific instructions
    shell> tar zxvf mysql-VERSION.tar.gz
    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/my-medium.cnf /etc/my.cnf
    shell> bin/mysqld_safe --user=mysql &
    # Next command is optional
    shell> cp support-files/mysql.server /etc/init.d/mysql.server

 

 

"no acceptable C compiler found in $PATH"解决手记

>[root@server mysql-5.0.56]# ./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking "character sets"... default: gbk, collation: gbk_chinese_ci; compiled in: gbk latin1 utf8
checking whether to compile national Unicode collations... yes
checking whether build environment is sane... yes
checking whether make sets $(MAKE)... (cached) yes
checking for gawk... (cached) gawk
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
今天在安装mysql时遇到了上面这个问题,解决办法:安装GCC软件套件
 [root@server mysql-5.0.56]# yum install gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
addons                                                   |  951 B     00:00   
addons/primary                                           |  202 B     00:00   
base                                                     | 1.1 kB     00:00   
base/primary                                             | 961 kB     00:06   
base                                                                  2705/2705
extras                                                   | 2.1 kB     00:00   
extras/primary_db                                        | 171 kB     00:00   
updates                                                  | 1.9 kB     00:00    
..........................................................................................
.................................................................................
................................................................
再次运行上面命令安装mysql即可以正常安装:
[root@server mysql-5.0.56]# ./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory
checking build system type... i686-redhat-linux-gnu
checking host system type... i686-redhat-linux-gnu
checking target system type... i686-redhat-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking "character sets"... default: gbk, collation: gbk_chinese_ci; compiled in: gbk latin1 utf8
checking whether to compile national Unicode collations... yes
checking whether build environment is sane... yes
checking whether make sets $(MAKE)... (cached) yes
checking for gawk... (cached) gawk
.............................................................................................................
..............................................................................................
....................................................................

 

 

 

 

安装mysql,在./configure时出现错误:error: No curses/termcap library found的解决办法

mysql版本:5.1.30

 

已经不记得这次是第几次安装mysql了,遇到这个问题倒是第一次。

之前在tar./configuremakemake install 经典四步时,从来没有想过其中的过程,只觉得像例行公事一样,做就是了。

不幸的是,这次在./configure后,make时出现以下错误:

make: *** No targets specified and no makefile found. stop.

 

本来这次还是想向别人请教的,后来转念一想,前段时间还告诉自己:遇到问题,首先想到自己解决。

 

于是,在网上找到相关资料,确认是./configure出了问题,于是回头查看,果然发现问题:

最后几行出了错。完整错误信息如下:

checking for tgetent in -lncurses... no

checking for tgetent in -lcurses... no

checking for tgetent in -ltermcap... no

checking for tgetent in -ltinfo... no

checking for termcap functions library... configure: error: No curses/termcap library found

 

原因:

缺少ncurses安装包

 

解决办法:

下载安装相应软件包

一、如果你的系统是RedHat系列:

yum list|grep ncurses

yum -y install ncurses-devel

yum install ncurses-devel

 

二、如果你的系统是UbuntuDebian

apt-cache search ncurses

apt-get install libncurses5-dev

 

待安装completed!之后,再./configure,顺利通过,然后make && make install,成功安装,一切OK~~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值