之所以写这篇文章,是因为找网上的好多种方法,都没有适合自己的。反而出现各种各样的错误。我今天把我在linux上成功安装的步骤在这里贴出来,希望对有些人能有点帮助。

一、下载安装mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz两个源文件

(1)先安装cmake(mysql5.5以后是通过cmake来配置的)

>tar -zxv -f cmake-2.8.4.tar.gz

>cd cmake-2.8.4

>./configure

>make

>make install

(2)创建mysql的安装目录及数据库存放目录

>mkdir -p /usr/local/mysql                 //安装mysql

>mkdir -p /usr/local/mysql/data            //存放数据库

(3)创建mysql用户及用户组(有可能之前已经加了,但是自己没注意,如果提示用户组已经存在,没有关系的)

>groupadd mysql

>useradd -r -g mysql mysql

(4)安装mysql

先复制代码到linux纯目录下

>tar -zxv -f mysql-5.5.10.tar.gz

>cd mysql-5.5.10

> cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1

>make

>make install

(5)复制mysql 库文件到/lib/目录,让使用到数据库的代码能找到库

>cp /usr/local/mysql/lib/* /lib/ -a

(6)修改mysql root用户密码为123456(这不可能会提醒你有错误,但是没关系,进行下一步操作)

>mysqladmin -u root password 123456

(7)重启mysql服务

> service mysqld restart

(8)如果# service mysqld start 启动失败,则:

# service mysqld start
初始化 MySQL 数据库:如出现错误 :

Neither host 'localhost.localdomain' nor 'localhost' could be looked up with
/usr/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
[失败]
解决办法:
1、$ ping localhost
ping: unknown host localhost
ping也不成功,确定可能为localhost解析原因。
2、查看/etc/hosts,内容如下:
# Do not remove the following line, or various programs
# that require network functionality will fail.
::1 localhost.localdomain localhost
3、将::1修改为127.0.0.1后,保存退出。

# ping localhost    此时已经能ping 通
4、改完后重启mysql:
(1)#service mysqld restart

如果想关闭:service mysqd stop

 

posted on 2013-12-29 18:18  story-wine  阅读(337)  评论(0)    收藏  举报