竞博体育 > 数据 > 竞博体育权限问题,下载的源码mysql

竞博体育权限问题,下载的源码mysql

CentOS 6.2编译安装MySQL 5.5.25

从mysql-cluster-gpl-7.2.8.tar.gz来安装mysql5.5.27

一、安装cmake

 

 

# 安装所需依赖包

之前虚拟机里装的系统都是ubuntu,后来同事说一般的服务器都是安装的centos,所以又重新倒腾了centos系统。  www.2cto.com  

#! /bin/sh    www.2cto.com  

yum -y install gcc libxml2-dev curl screen

  当然,首先得搭建PHP环境。下载的源码mysql,版本是5.5.25,最新的好像是5.5.4。这里记住,一定要下载源码,在mysql官网下载时,会提示你选择平台,选择下拉菜单中的最底下一个Source Code。

# install mysql 5.5.27 through mysql-cluster-gpl-7.2.8.tar.gz

libpng12-dev autoconf libpcre3-dev make bzip2

  按照之前ubuntu安装的步骤安装后,启动mysql启动不起来。错误代码为“ The server quit without updating PID file(/var/lib/mysql/CentOS.pid)”,百度和google都搜索了一些资料,基本一致,对我没帮助,按照他们说的修改了也不行。于是乎结合张晏的博客,最终成功搞定。  

#竞博体育 , add path

libevent-dev patch libjpeg62-dev libcurl4-openssl-dev

第一步:我们首先安装依赖库和开发工具

mkdir -p /var/lib/mysql

libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz

 

# add data path

 

#依赖库和开发工具  

mkdir -p /var/lib/data/mysql

# 下载文件

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

# groupadd mysql

wget

  www.2cto.com  

# useradd -g mysql mysql

  www.2cto.com  

#Nginx

chown -R mysql:mysql /var/lib/

# 编译安装

yum -y install pcre-devel  zlib-devel

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers bison cmake

tar zxvf cmake-2.8.5.tar.gz

 

cp /home/guanli/mysql-cluster-gpl-7.2.8.tar.gz /var/lib

cd cmake-2.8.5

#Php

cd /var/lib

./boostarp

yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel

tar -zvxf mysql-cluster-gpl-7.2.8.tar.gz

make

 

mv mysql-cluster-gpl-7.2.8 mysql5.5.27

make install

#Mysql

cd mysql5.5.27

cmake –version

yum -y install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel

# rm CMakeCache.txt

 

 

cmake -DCMAKE_INSTALL_PREFIX=/var/lib/mysql  -DMYSQL_DATADIR=/var/lib/data/mysql  -DINSTALL_SBINDIR=/var/lib/mysql/sbin  -DSYSCONFDIR=/etc  -DINSTALL_PLUGINDIR=/var/lib/mysql/lib64/mysql/plugin  -DINSTALL_MANDIR=/var/lib/mysql/share/man  -DINSTALL_SHAREDIR=/var/lib/mysql/share  -DINSTALL_LIBDIR=/var/lib/mysql/lib64/mysql  -DINSTALL_INCLUDEDIR=/var/lib/mysql/include/mysql  -DINSTALL_INFODIR=/var/lib/mysql/share/info  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_MYISAM_STORAGE_ENGINE=1   -DWITH_READLINE=1 -DWITH_SSL=system  -DWITH_ZLIB=system  -DWITH_LIBWRAP=0   -DMYSQL_TCP_PORT=3306  -DMYSQL_UNIX_ADDR=/var/lib/data/mysql/mysql.sock  -DENABLED_LOCAL_INFILE=1  -DEXTRA_CHARSETS=all  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EMBEDDED_SERVER=1  -DMYSQL_USER=mysql  -DWITH_DEBUG=0  -DENABLE_PROFILING=0  -DWITH_COMMENT='string' 

二、 安装配置mysql

  第二步:由于mysql5.5开始,不再使用configure安装,而是使用cmake。所以需要先安装cmake

make && make install

# 下载源文件

wget

cp support-files/my-medium.cnf /etc/my.cnf

wget

tar -zxvf cmake-2.8.6.tar.gz

# chmod a+rwx /scripts/mysql_install_db

# 或

cd cmake-2.8.6/

./scripts/mysql_install_db --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/data/mysql

wget ftp://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz

./configure

 

 

make && make install  

# /var/lib/mysql/bin/mysqld_safe & 目前启动不了,有好多问题,待更新。

# 创建用户和组

  第三步:cmake安装mysql(我已经下载好了mysql源码文件,放在U盘里,拷贝到/tmp目录下)

 

groupadd mysql

 

问题1:在利用cmake编译的时候,该用相对路径的时候必须用相对路径,不能用绝对路径,否则会出错。  www.2cto.com  

useradd -g mysql  -s /usr/sbin/nologin  mysql

//进入/tmp目录下

 

 

tar -zxvf mysql-5.5.25.tar.gz

解决办法:将配置命令改为:

# 创建安装目录

cd mysql-5.5.25

 

mkdir  /usr/local/ mysql

  www.2cto.com  

cmake -DCMAKE_INSTALL_PREFIX=/var/lib/mysql  -DMYSQL_DATADIR=/var/lib/data/mysql  -DINSTALL_SBINDIR=sbin  -DSYSCONFDIR=/etc  -DINSTALL_PLUGINDIR=lib64/mysql/plugin  -DINSTALL_MANDIR=share/man  -DINSTALL_SHAREDIR=share  -DINSTALL_LIBDIR=lib64/mysql  -DINSTALL_INCLUDEDIR=include/mysql  -DINSTALL_INFODIR=share/info  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_MYISAM_STORAGE_ENGINE=1   -DWITH_READLINE=1 -DWITH_SSL=system  -DWITH_ZLIB=system  -DWITH_LIBWRAP=0   -DMYSQL_TCP_PORT=3306  -DMYSQL_UNIX_ADDR=/var/lib/data/mysql/mysql.sock  -DENABLED_LOCAL_INFILE=1  -DEXTRA_CHARSETS=all  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EMBEDDED_SERVER=1  -DMYSQL_USER=mysql  -DWITH_DEBUG=0  -DENABLE_PROFILING=0  -DWITH_COMMENT='string'

 

cmake

问题2:121212 01:55:07 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql/data /var/lib/mysql/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13) 121212  1:55:08 [ERROR] Aborting

# 创建数据库目录

-DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql

 

mkdir  /usr/local/ mysql/data

-DMYSQL_DATADIR=/user/local/webserver/mysql/data

解决:权限问题。# chown -R mysql:mysql /var/lib/

   www.2cto.com  

-DSYSCONFDIR=/etc

 

# 解压

-DEXTRA_CHARSETS=all

#! /bin/sh www.2cto.com # install mysql 5.5.27 through mysql-cluster-gpl-7.2.8.tar.gz # add path mkdir -p /var/lib/mysql # add...

tar -zxvf mysql-5.5.17.tar.gz

-DDEFAULT_CHARSET=utf8

cd mysql-5.5.17

-DDEFAULT_COLLATION=utf8_general_ci

 

-DWITH_INNOBASE_STORAGE_ENGINE=1

# 编译及安装mysql

-DWITH_ARCHIVE_STORAGE_ENGINE=1

# cmake编译: 

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DWITH_FEDERATED_STORAGE_ENGINE=1

-DMYSQL_DATADIR=/usr/local/mysql/data

-DWITH_PARTITION_STORAGE_ENGINE=1

-DDEFAULT_CHARSET=utf8

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1

-DDEFAULT_COLLATION=utf8_unicode_ci

-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock

-DWITH_READLINE=1

-DMYSQL_TCP_PORT=3306

-DWITH_SSL=system  

-DWITH_DEBUG=0

-DWITH_EMBEDDED_SERVER=1

-DENABLED_LOCAL_INFILE=1

-DENABLED_LOCAL_INFILE=1

 

-DDEFAULT_COLLATION=utf8_general_ci

回车执行,执行完成后继续执行 make && make install

-DWITH_MYISAM_STORAGE_ENGINE=1

  第四步:设置mysql

-DWITH_INNOBASE_STORAGE_ENGINE=1

 

-DWITH_DEBUG=0

#设置Mysql

   www.2cto.com  

#在support-files目录中有五个配置信息文件(这里很重要,一定要根据自己的内存复制对应的cnf文件,否则mysql始终起不来):  www.2cto.com  

# 安装mysql

#my-small.cnf (内存<=64M)

make && make install

#my-medium.cnf (内存 128M)

 

#my-large.cnf (内存 512M)

# 复制配置文件

#my-huge.cnf (内存 1G-2G)

cp support-files/my-medium.cnf  /etc/my.cnf

#my-innodb-heavy-4G.cnf (内存 4GB)

 

cd /usr/local/webserver/mysql

# 设置权限

cp ./support-files/my-huge.cnf /etc/my.cnf 

chmod +x /usr/local/mysql

vi /etc/my.cnf

chown -R mysql.mysql /usr/local/mysql

#在 [mysqld] 段增加

chown -R mysql:mysql /usr/local/mysql/data

datadir = /data/mysql

 

wait-timeout = 30

# 配置开机自启动

max_connections = 512

cp support-files/mysql.server /etc/init.d/mysqld

default-storage-engine = MyISAM

chmod +x /etc/init.d/mysqld

#在 [mysqld] 段修改

chkconfig –add mysqld

max_allowed_packet = 16M 

chkconfg mysqld on

 

   www.2cto.com  

第五步:添加mysql用户和用户组,生成新的mysql授权表

# 修改my.cnf配置

 

vim /etc/my.cnf

//添加mysql运行的用户和用户组

# [mysqld] 添加:

groupadd mysql

datadir=/usr/local/mysql/data

useradd -g mysql mysql -s /bin/false -d /home/mysql  //没有shell,不可本机登陆(安全起见)  www.2cto.com  

default-storage-engine=MyISAM

 

 

cd /usr/local/webserver/mysql

# 以下可选:

chown -R root .

log-error =/usr/local/mysql/data/error.log

chown -R mysql data

pid-file = /usr/local/mysql/data/mysql.pid

chgrp -R mysql .

user = mysql

 

tmpdir = /tmp

//生成新的mysql授权表

 

//进入mysql安装目录下的脚本目录

# 初始化数据库

cd /usr/local/webserver/mysql/scripts

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &

//利用mysql_install_db脚本生成新的mysql授权表

 

./mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=mysql

# 启动MySQL

 

/usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf &

//mysql server在系统中的服务项设置

或者:

//复制服务文件并修改

/etc/init.d/mysql start (service mysql start)

cd /usr/local/webserver/mysql/support-files

   www.2cto.com  

cp mysql.server mysqld

# 测试MySQL是否启动

//修改mysqld

# 1)查看是否有进程mysql

basedir=/usr/local/webserver/mysql

ps -ef | grep mysql

datadir=/usr/local/webserver/mysql/data

# 2)查看端口是否运行

  www.2cto.com  

netstat -tnl | grep 3306

mv mysqld /etc/init.d/mysqld

# 3)读取mysql版本信息

chmod 755 /etc/init.d/mysqld

/usr/local/mysql/bin/mysqladmin version

 

 

//设置软连接使mysql,  mysqldump,  mysqladmin这三个bin命令能在shell中直接运行

# 至此,MySQL安装完成  

sudo ln -s /usr/local/webserver/mysql/bin/mysql /usr/bin

# 安装所需依赖包 yum -y install gcc libxml2-dev curl screen libpng12-dev autoconf libpcre3-dev make bzip2 libevent-dev patch libjpeg62-dev libcurl4-ope...

sudo ln -s /usr/local/webserver/mysql/bin/mysqldump /usr/bin

sudo ln -s /usr/local/webserver/mysql/bin/mysqladmin /usr/bin

 

rm -rf /etc/mysql/my.cnf 因为已经把此文件复制到/etc/my.cnf  如果不删除的话,mysql启动不起来。

 

第六步:启动mysql,设置mysql用户名和密码

 

/etc/init.d/mysqld start

 

//设置root密码

mysqladmin -u root password "admin"

  www.2cto.com  

//mysql数据库中文乱码解决

vi /etc/my.cnf

//然后在[mysqld]配置选项下添加

character-set-server=utf8

 

//然后进入mysql

cd /usr/local/webserver/mysql/bin

mysql -u root -p

提示输入密码

mysql> show variables like '%character%';

//结果:character_set_database,character_set_server两项都变为utf8了

 

 

作者 HQER

6.2编译安装MySQL 5.5.25 之前虚拟机里装的系统都是ubuntu,后来同事说一般的服务器都是安装的centos,所以又重新倒腾了centos系统。 www...

下一篇:没有了
  • 首页
  • 电话
  • 软件