`
ssxxjjii
  • 浏览: 944872 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

centos的5.2,mysql免安装版本

阅读更多

centos的版本是5.2,mysql的版本是最新的稳定版本5.1.30. 我的安装包是mysql-5.1.30-linux-i686-glibc23.tar.gz。该版本是免编译版本。安装过程中不需要make。第一次安 装免编译版,第一次安装5.1,安装过程中还是碰到了一些问题。不过,历尽千辛,一切ok了。

          我把mysql-5.1.30-linux-i686-glibc23.tar.gz放在/home/xjj/soft下。先进入该目录解压。

 

Java代码
  1.  [root @localhost  soft]# cd /home/xjj/soft      
  2.    [root@localhost  soft]# tar -zvxf mysql- 5.1 . 30 -linux-i686-glibc23  
  3. [root@localhost  soft]# cd mysql- 5.1 . 30 -linux-i686-glibc23  
  4.    [root@localhost  mysql- 5.1 . 30 -linux-i686-glibc23]# ls  
  5.      bin      docs   INSTALL-BINARY  mysql-test  share  
  6. COPYING  EXCEPTIONS-CLIENT  lib             README      sql-bench  
  7. data     include            man             scripts     support-files  
 [root@localhost soft]# cd /home/xjj/soft    
   [root@localhost soft]# tar -zvxf mysql-5.1.30-linux-i686-glibc23
[root@localhost soft]# cd mysql-5.1.30-linux-i686-glibc23
   [root@localhost mysql-5.1.30-linux-i686-glibc23]# ls
     bin      docs   INSTALL-BINARY  mysql-test  share
COPYING  EXCEPTIONS-CLIENT  lib             README      sql-bench
data     include            man             scripts     support-files

 

     可以看到,加压后的目录中并没有configure目录。所以如果你运行./configure的话,会出现找不到文件的错误,我就浪费了时间在这上面。先将加压后的目录mv到/usr/local下

 

Java代码
  1. [root @localhost  mysql- 5.1 . 30 -linux-i686-glibc23]# mv mysql- 5.1 . 30 -linux-i686-glibc23/ /usr/local/mysql  
  2.  [root@localhost  mysql- 5.1 . 30 -linux-i686-glibc23]# cd /usr/local/mysql  
[root@localhost mysql-5.1.30-linux-i686-glibc23]# mv mysql-5.1.30-linux-i686-glibc23/ /usr/local/mysql
 [root@localhost mysql-5.1.30-linux-i686-glibc23]# cd /usr/local/mysql

 

     很重要的一步,是创建一个用户组,并在改组下创建一个用户。这里我们创建一个mysql组,并创建一个mysql用户。

 

Java代码
  1. [root @localhost  mysql- 5.1 . 30 -linux-i686-glibc23]# groupadd mysql  
  2. [root@localhost  mysql- 5.1 . 30 -linux-i686-glibc23]# useradd -g mysql mysql  
[root@localhost mysql-5.1.30-linux-i686-glibc23]# groupadd mysql
[root@localhost mysql-5.1.30-linux-i686-glibc23]# useradd -g mysql mysql

 

     下面添加mysql的配置文件,改文件的模板在mysql/support-files下,共有5个cnf配置文件,先看一下:

 

Java代码
  1. [root @localhost  mysql]# cd support-files/  
  2. [root@localhost  support-files]# ls  
  3.       binary-configure   my-huge.cnf             mysqld_multi.server  
  4.       config.huge.ini    my-innodb-heavy-4G.cnf  mysql-log-rotate  
  5.       config.medium.ini  my-large.cnf            mysql.server  
  6.       config.small.ini   my-medium.cnf           ndb-config-2 -node.ini  
  7.       magic              my-small.cnf  
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
      binary-configure   my-huge.cnf             mysqld_multi.server
      config.huge.ini    my-innodb-heavy-4G.cnf  mysql-log-rotate
      config.medium.ini  my-large.cnf            mysql.server
      config.small.ini   my-medium.cnf           ndb-config-2-node.ini
      magic              my-small.cnf

 

   改文件分别适应于不同的安装配置,具体说明如下。

Java代码
  1. my-small.cnf 最小配置安装,内存<=64M,数据数量最少  
  2. my-large.cnf               内存=512M  
  3. my-medium.cnf             32M<内存<64M,或者内存有128M,但是数据库与web服务器公用内存   
  4. my-huge.cnf               1G<内存<2G,服务器主要运行mysql  
  5. my-innodb-heavy-4G.cnf    最大配置安装,内存至少4G  
my-small.cnf 最小配置安装,内存<=64M,数据数量最少
my-large.cnf               内存=512M
my-medium.cnf             32M<内存<64M,或者内存有128M,但是数据库与web服务器公用内存 
my-huge.cnf               1G<内存<2G,服务器主要运行mysql
my-innodb-heavy-4G.cnf    最大配置安装,内存至少4G

 

  根据情况,我选择my-medium.cnf进行配置。

Java代码
  1. [root @localhost  mysql]# cp support-files/my-medium.cnf /etc/my.cnf  
 [root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf

 

  下面进行访问权限配置,用mysql_install_db创建MySQL授权表初始化,并设置mysql,root帐号访问权限

 

Java代码
  1. [root @localhost  mysql]# chown -R mysql .  
  2.     [root@localhost  mysql]# chgrp -R mysql .  
  3.     [root@localhost  mysql]# scripts/mysql_install_db –user=mysql  
  4.     Installing MySQL system tables…  
  5.     OK  
  6.     Filling help tables…  
  7.     OK  
  8. To start mysqld at boot time you have to copy  
  9. support-files/mysql.server to the right place for  your system  
  10. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !  
  11. To do  so, start the server, then issue the following commands:  
  12. ./bin/mysqladmin -u root password ‘new -password’  
  13. ./bin/mysqladmin -u root -h localhost.localdomain password ‘new -password’  
  14. Alternatively you can run:  
  15. ./bin/mysql_secure_installation  
  16. which will also give you the option of removing the test  
  17. databases and anonymous user created by default .  This is  
  18. strongly recommended for  production servers.  
  19. See the manual for  more instructions.  
  20. You can start the MySQL daemon with:  
  21. cd . ; ./bin/mysqld_safe &  
  22. You can test the MySQL daemon with mysql-test-run.pl  
  23. cd ./mysql-test ; perl mysql-test-run.pl  
  24. Please report any problems with the ./bin/mysqlbug script!  
  25. The latest information about MySQL is available at http://www.mysql.com/   
  26. Support MySQL by buying support/licenses from http://shop.mysql.com/   
  27. [root@localhost  mysql]# chown -R root  
  28. chown: “root” 后缺少操作数  
  29. 请尝试执行“chown –help”来获取更多信息。  
  30. [root@localhost  mysql]# chown -R root .  
  31. [root@localhost  mysql]# chown -R mysql data  
[root@localhost mysql]# chown -R mysql .
    [root@localhost mysql]# chgrp -R mysql .
    [root@localhost mysql]# scripts/mysql_install_db –user=mysql
    Installing MySQL system tables…
    OK
    Filling help tables…
    OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password ‘new-password’
./bin/mysqladmin -u root -h localhost.localdomain password ‘new-password’
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
[root@localhost mysql]# chown -R root
chown: “root” 后缺少操作数
请尝试执行“chown –help”来获取更多信息。
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql data

 

  
     特别注意,[root@localhost mysql]# chown -R root .这里的.号是不能少的。好了,开始启动mysql。

 

Java代码
  1. [root @localhost  mysql]# bin/mysqld_safe –user=mysql &  
  2. 090105   16 : 57 : 45  mysqld_safe Logging to ‘/var/log/mysqld.log’.  
  3. 090105   1657 : 46  mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  
  4. 090105   16 : 57 : 49  mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended  
[root@localhost mysql]# bin/mysqld_safe –user=mysql &
090105 16:57:45 mysqld_safe Logging to ‘/var/log/mysqld.log’.
090105 1657:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
090105 16:57:49 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

 

   启动失败,查看/var/log/mysqld.log中的日志,看看具体的原因。

Java代码
  1. [root @localhost  mysql]# less /var/log/mysqld.log  
  2. …………..  
  3. InnoDB: Apply batch completed  
  4. 090105   17 : 03 : 31   InnoDB: Started; log sequence number  0   46409   
  5. 090105   17 : 03 : 31  [ERROR] /usr/local/mysql/bin/mysqld: Can’t create/write to file   
  6. ‘/var/run/mysqld/mysqld.pid’ (Errcode: 2 )  
  7. 090105   17 : 03 : 31  [ERROR] Can’t start server: can’t create PID file: No such file   
  8. or directory  
  9. 090105   17 : 03 : 31  mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended  
[root@localhost mysql]# less /var/log/mysqld.log
…………..
InnoDB: Apply batch completed
090105 17:03:31  InnoDB: Started; log sequence number 0 46409
090105 17:03:31 [ERROR] /usr/local/mysql/bin/mysqld: Can’t create/write to file 
‘/var/run/mysqld/mysqld.pid’ (Errcode: 2)
090105 17:03:31 [ERROR] Can’t start server: can’t create PID file: No such file 
or directory
090105 17:03:31 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

 

   原来是/var/run/mysqld/mysqld.pid不存在,看来要手动创建它了,不要忘记了进行授权。

Java代码
  1. [root @localhost  log]# mkdir /var/run/mysqld  
  2. [root@localhost  log]# cd /var/run/mysqld  
  3. [root@localhost  mysqld]# touch mysqld.pid  
  4. [root@localhost  mysqld]# chown -R mysql mysqld.pid  
  5. [root@localhost  mysqld]# cd /usr/local/mysql  
[root@localhost log]# mkdir /var/run/mysqld
[root@localhost log]# cd /var/run/mysqld
[root@localhost mysqld]# touch mysqld.pid
[root@localhost mysqld]# chown -R mysql mysqld.pid
[root@localhost mysqld]# cd /usr/local/mysql

 

  再次启动mysql,并给root用户设置初始密码。

Java代码
  1. [root @localhost  mysql]# bin/mysqld_safe –user=mysql &  
  2. [root@localhost  mysql]# bin/mysqld_safe –user=mysql &  
  3. [1 5789   
  4. [root@localhost  mysql]#  090105   17 : 32 : 31  mysqld_safe Logging to ‘/var/log/mysqld.log’.  
  5. 090105   17 : 32 : 31  mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  
  6. [root@localhost  mysql]# bin/mysqladmin -u root password  123   
  7. bin/mysqladmin: connect to server at ‘localhost’ failed  
  8. error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2 )’  
  9. Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists!  
[root@localhost mysql]# bin/mysqld_safe –user=mysql &
[root@localhost mysql]# bin/mysqld_safe –user=mysql &
[1] 5789
[root@localhost mysql]# 090105 17:32:31 mysqld_safe Logging to ‘/var/log/mysqld.log’.
090105 17:32:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@localhost mysql]# bin/mysqladmin -u root password 123
bin/mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists!

 

  从错误提示可以看出,可能是/tmp/mysql.sock不存在。

Java代码
  1. [root @localhost  mysql]# cd /tmp  
  2. [root@localhost  tmp]# ls  
  3. gconfd-root     scim-bridge-0.3 . 0 .lockfile- 0 @localhost : 0.0   ssh-yocCKF5691  
  4. keyring-ej0c48  scim-bridge-0.3 . 0 .socket- 0 @localhost : 0.0     virtual-root.8cYaYH  
  5. keyring-RtFEN5  scim-helper-manager-socket-root             virtual-root.v3vfmO  
  6. mapping-root    scim-panel-socket:0 -root  
  7. orbit-root      scim-socket-frontend-root  
[root@localhost mysql]# cd /tmp
[root@localhost tmp]# ls
gconfd-root     scim-bridge-0.3.0.lockfile-0@localhost:0.0  ssh-yocCKF5691
keyring-ej0c48  scim-bridge-0.3.0.socket-0@localhost:0.0    virtual-root.8cYaYH
keyring-RtFEN5  scim-helper-manager-socket-root             virtual-root.v3vfmO
mapping-root    scim-panel-socket:0-root
orbit-root      scim-socket-frontend-root

 

  确实不存在mysql.sock文件。一般情况下,mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock中,
我们创建一个符号连接即可。

 

Java代码
  1. [root @localhost  mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock  
[root@localhost mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

 

  再次设置root密码,并登录。

Java代码
  1. [root @localhost  mysql]# bin/mysqladmin -u root password  123   
  2. [root@localhost  mysql]# bin/mysql -u root -p  
  3. Enter password:   
  4. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  5. Your MySQL connection id is 3   
  6. Server version: 5.1 . 30  MySQL Community Server (GPL)  
  7. Type ‘help;’ or ‘\h’ for  help. Type ‘\c’ to clear the buffer.  
[root@localhost mysql]# bin/mysqladmin -u root password 123
[root@localhost mysql]# bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.30 MySQL Community Server (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

 

 终于看到久违的熟悉界面了。下面,我们还要配置一下,以便mysql能够开机自启动。

Java代码
  1. [root @localhost  mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld  
  2. [root@localhost  mysql]# chmod  700  /etc/init.d/mysqld  
  3. [root@localhost  mysql]# chkconfig –add mysqld  
  4. [root@localhost  mysql]# chkconfig –level  345  mysqld on  
[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chmod 700 /etc/init.d/mysqld
[root@localhost mysql]# chkconfig –add mysqld
[root@localhost mysql]# chkconfig –level 345 mysqld on

 

 

好了,可以了,然后可以运行service mysqld start 启动mysql。相应的命令还有。

 

{start|stop|restart|reload|force-reload|status}

 

大家应该很容易理解它们的意思。

分享到:
评论

相关推荐

    CentOS5.2图示安装

    《CentOS5.2 图示安装详解:新手友好指南》 CentOS 5.2 是一个基于Linux的服务器操作系统,以其稳定性和强大的企业级功能而备受赞誉。对于初学者来说,进行一次完整的安装可能显得有些复杂,但通过图示化的安装步骤...

    Linux(centOS5.2)图文教程

    Linux(centOS5.2)图文教程 自己编写,希望对你有帮助

    CentOS 5.2 AMD 64 Apache Php Mysql 配置

    CentOS 5.2中的PHP版本可能较旧,所以需要手动安装更新的版本: ```bash rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm yum --enablerepo=remi install php php-mysql -y ``` 这将安装...

    Centos5.2安装过程[VMware虚拟机]

    《CentOS 5.2 在 VMware 虚拟机中的安装步骤详解》 在IT领域,熟练掌握操作系统安装是基础技能之一,尤其是对于Linux系统,如CentOS。本文将详细介绍如何在VMware虚拟机上安装CentOS 5.2,这对于初学者来说是一份极...

    CentOS7环境mysql小版本升级步骤

    在CentOS7环境下,对MySQL的小版本升级是一个关键的维护任务,以确保数据库系统的稳定性和安全性。本文将详细阐述如何从MySQL 5.7.26升级到5.7.31,这是一个典型的二进制文件替换升级方法。以下是具体的步骤: 一、...

    centos5.2安装文档

    linux centos5.2图形安装手册

    Linux下MySql免安装

    1. **解压MySQL免安装包** 首先,你需要获取MySQL的免安装包,这通常可以从MySQL官方网站下载,或者使用自己预先准备好的压缩文件。在描述中提到的是`/usr/local/mysql-noinstall-5.1.48-linux.tgz`,这个路径表示...

    基于 CentOS 5.2 的RHCS 的高可用性解决方案

    基于 CentOS 5.2 的RHCS 的高可用性解决方案基于 CentOS 5.2 的RHCS 的高可用性解决方案

    CentOS 5.2 下安装JDK

    本TXT文件为第一章:Linux 下安装 JDK 测试环境:系统 CentOS 5.2 第一步:查看Linux自带的JDK是否已安装并卸载…… 第二步:安装JDK步骤…… 第三步:配置环境变量 三步完成安装 其他安装请见...

    CentOS5.2 jsp服务器

    【标题】:“CentOS5.2 jsp服务器” 在IT领域,CentOS 5.2 是一个基于Linux的开源操作系统,它广泛应用于服务器环境,尤其是作为Web服务的基础。本主题聚焦于如何在CentOS 5.2上配置并运行一个支持JSP(JavaServer ...

    Centos5.0-5.2_32x64dvd镜像下载种子.rar

    Centos历史版本资源下载,Centos5.0-5.2_32x64dvd镜像下载种子torrent

    CentOs5.2下安装php5.0.4及eaccelerator

    NULL 博文链接:https://yy-web.iteye.com/blog/272348

    CentOS 5.2下安装Tomcat5.5

    本TXT文件为第二章Linux 下安装 Tomcat5.5 测试环境:系统 CentOS 5.2 Tomcat版本apache-tomcat-5.5.23 第一步:解压缩Tomcat部署文件到 /usr/local/tomcat 第二步:测试安装(注意环境变量JAVA_HOME必需...

    centos5.2下配置apache+mysql+php

    ### CentOS 5.2 下配置 Apache + MySQL + PHP 在 CentOS 5.2 系统上搭建 LAMP(Linux + Apache + MySQL + PHP)环境是一项常见的任务,它为 Web 开发提供了一个强大的平台。本文将详细介绍如何从源码安装 Apache、...

    CentOS 5.2 下安装 FreePBX 2.5.0

    CentOS 5.2 下安装 FreePBX 2.5.0

    CentOS5.2系统安装在虚拟机上,编译gcc.pdf

    CentOS 5.2版本发布于2008年,其官方支持已于2017年3月31日结束。安装CentOS 5.2系统通常需要选择合适的虚拟化软件,例如VMware Workstation、VirtualBox等,虚拟机环境允许用户在隔离的环境中运行一个完整的操作...

    Centos 5.2 下 ORACLE 10G安装笔记-详细(图)

    Centos 5.2 下 ORACLE 10G安装

    CentOS5.2挂NTFS文件系统

    CentOS5.2下使用NTFS文件系统

Global site tag (gtag.js) - Google Analytics