您的位置:首页 > 运维架构 > Linux

CentOS 5.5 安装 mysql5.1

2014-01-17 16:24 253 查看
本文转自网络,部分内容为后来添加,实际动手安装成功。

[MySQL安装前添加用户和群组]

groupadd mysql

useradd -g mysql mysql -s /sbin/nologin

配置编译参数

# ./configure --prefix=/usr/local/mysql \

--enable-thread-safe-client \

--enable-assembler \

--enable-local-infile \

--enable-largefile \

--with-charset=gbk \

--with-collation=gbk_chinese_ci \

--with-extra-charsets=complex \

--with-pthread \

--with-unix-socket-path=/var/tmp/mysql.sock \

--with-mysqld-user=mysql \

--with-mysqld-ldflags=-all-static \

--with-client-ldflags=-all-static \

--with-big-tables \

--with-ssl \

--with-plugins=partition,innobase \

--with-embedded-server \

--with-readline \

--without-debug

# make && make install && make clean

# chmod +w /usr/local/mysql

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

编译MySQL的过程中提示:

/bin/rm: cannot remove `libtoolt': No such file or directory

解决:

1、确认libtool是否已经安装,如果没有安装的话,则先安装libtool

# yum -y install libtool

2、分别执行以下三条命令:

# autoreconf --force --install

# libtoolize --automake --force

# automake --force --add-missing

再重新编译安装,问题解决!

初始化数据库

# /usr/local/mysql/bin/mysql_install_db --user=mysql

报错:

# ./mysql_install_db --user=mysql 

Neither host 'macd' nor 'localhost' could be looked up with

/usr/local/mysql/bin/resolveip

Please configure the 'hostname' command to return a correct

hostname.

If you want to solve this at a later stage, restart this script

with the --force option

解决办法:

# vi /etc/hosts

添加

127.0.0.1 localhost

启动mysql

# /usr/local/mysql/bin/mysqld_safe --user=mysql &

报错:

# 120208 09:30:16 mysqld_safe Logging to '/var/log/mysqld.log'.

120208 09:30:16 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

120208 09:30:16 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

日志文件中记录的错误

120208  9:30:16 [ERROR] /usr/local/mysql/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)

120208  9:30:16 [ERROR] Can't start server: can't create PID file: No such file or directory

120208 09:30:16 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

解决办法:

# mkdir /var/run/mysqld

# chown -R mysql /var/run/mysqld

# chgrp -R mysql /var/run/mysqld

设置数据库管理员root帐号的密码

# mysqladmin -u root password mxy1858

添加mysql到系统服务中开机自动启动

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

# chmod +x /etc/init.d/mysqld

# chkconfig --add mysqld

# chkconfig mysqld on

创建/etc/my.cnf配置文件

创建一个具有root权限的用户(admin)和密码(12345678)用于远程管理

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY '123456789';

在iptables中开启3306端口否则远程无法访问

-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 3306 --state NEW -j ACCEPT
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos linux mysql