Home > Database > Mysql Tutorial > body text

Debain下编译安装mysql_MySQL

WBOY
Release: 2016-06-01 13:32:26
Original
919 people have browsed it

bitsCN.com

Debain下编译安装mysql

 

1. 做好前提准备 安装 需要使用的 ...

 

#二进制文件( 如果你自己提供的文件,一定要注意不要版本错了)

wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.12.tar.gz/from/http://mysql.he.net/

 

#cmake 编译

wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

 

wget http://ftp.gnu.org/gnu/bison/bison-2.4.3.tar.gz

 

apt-get install make  // 网络资源地址没找  有的留个

2.  安装cmake

 

cd /usr/local/

 

tar zxvf cmake-2.8.4.tar.gz         //下载的cmake文件路径

 

cd cmake-2.8.4

 

./bootstrap

 

make

 

make install

3. 安装 bison

 

tar zxvf bison-2.4.3.tar.gz

 

cd bison-2.4.3

 

./configure

 

make

 

make install

1.configure: error: no acceptable C compiler found in $PATH

原因: 没有安装  GCC 编译器

解决:  apt-get install gcc

4 编译安装 mysql

 

# 创建用户

 

groupadd mysql

 

useradd -g mysql mysql

 

cd /usr/local

 

tar zxvf ../mysql-5.5.12.tar.gz  // 我把二进制文件放在 /usr下面

 

cd  mysql-5.5.12

 

## 编译二进制文件 

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql /

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock /

-DDEFAULT_CHARSET=utf8 /

-DDEFAULT_COLLATION=utf8_general_ci /

-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk /

-DWITH_MYISAM_STORAGE_ENGINE=1 /

-DWITH_INNOBASE_STORAGE_ENGINE=1 /

-DWITH_MEMORY_STORAGE_ENGINE=1 /

-DWITH_READLINE=1 /

-DENABLED_LOCAL_INFILE=1 /

-DMYSQL_DATADIR=/var/mysql/data /

-DMYSQL_USER=mysql

 

make  //  这一步时间有点长 (这个文件夹的包含CMakeLists.txt)

 

make install 

  # 修改用户和权限

 

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql

chmod +w /usr/local/mysql

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

mkdir -p /var/mysql/

 

mkdir -p /var/mysql/data/

mkdir -p /var/mysql/log/

chown -R mysql:mysql /var/mysql/

 

cd support-files/

cp my-large.cnf /var/mysql/my.cnf(如果是debian,my.conf需要放在/etc/mysql/下面)

cp mysql.server /etc/init.d/mysqld

2.FATAL ERROR: Could not find mysqld (命令提示记得不是太清楚了,意思就是 mysqld命令找不到)

解决方法  ln -sf /usr/local/mysql/bin/* /usr/bin

3 FATAL ERROR: Could not find errmsg.sys  

原因:在特定的路径下面访问不到这个文件, 如果你只是把这一个文件拷贝过去的话 下面还会出现

同样的问题,因为他依赖于  /usr/local/mysql/share 文件夹  我直接拷贝过去, 或者创建软连接

 

解决方法

 

cd /usr/share/

 

mkdir mysql

cd mysql

 

cp -a /usr/local/mysql/share/* .

4 /usr/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object 

 

  file: No such file or directory

 安装 libaio-dev

 tips

 

 在网上查找原因的时候 说是没有apt-get update , 于是我无知的 apt-get update FUCK 无效,写文章

详细点  我这个linux  学徒 表示压力很大

进入下列网址  按照提示 修改 /etc/apt/sources.list

http://packages.debian.org/zh-cn/lenny/i386/libaio-dev/download

写好之后  在 apt-get update 

#安装

apt-get install libaio-dev

5. 110518 15:09:27 [ERROR] /usr/local/mysql/bin/mysqld: unknown option '--skip-bdb'

解决方法  vim /etc/mysql/my.cnf 将 skip-bdb 那行 注释掉

cary:/usr/local/mysql# scripts/mysql_install_db --datadir=/var/mysql/data/ --basedir=/usr/local/mysql 

--user=mysql

启动数据库 

 

/etc/init.d/mysqld start

这是我模拟的异常信息

 

/etc/init.d/mysqld: line 276: cd: /usr/local/mysq1l: No such file or directory

 

解决方法 vim /etc/mysql/my.cnf 下mysqld 的配置参数 要和上面你安装的 配置参数一致

 

如 my.cnf 中

 

[mysqld]

 

....

 

basedir         = /usr/local/mysq1l  参数改为 你上面配置的 /usr/local/mysql

  修改管理员密码

 

mysqladmin -uroot password '123456'

Starting MySQL....The server quit without updating PID file (/var/run/mysqld/mysqld.pid). failed!

 

解决方法 

 

pkill -f mysql 

 

rm /var/run/mysql/*

 

重新启动 mysql

如果你下载好的是编译好的文件 那么你就不需要Cmake 编译 可以跳过那一步

 

创建远程用户登录不了??

 

vim /etc/mysql/my.cnf

 

将 bind-address 127.0.0.1 注释掉

 

bitsCN.com
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!