• [置顶] linux 解压版安装


    1:下载mysql解压版包去官网下载www.mysq.com 下载。下载linux通用版本就好了    

    2、基本配置

     

    首先,我们准备好Linux环境,我们使用CentOS 5.8进行试验安装。第一步,我们需要将下载好的MySQL压缩版通过FTP/SFTP上传到Linux服务器上。

     

     

    --创建目录

    [root@bspdev ~]# cd /

    [root@bspdev /]# mkdir mysql

    [root@bspdev /]# ls -l | grep mysql

    drwxr-xr-x  2 root root 4096 Jul 1 03:56 mysql

     

     

    使用FTP/SFTP软件,将压缩包(mysql-5.5.25-linux2.6-i686.tar.gz)上传到指定目录,并且解压。

     

     

    [root@bspdev /]# cd mysql

    [root@bspdev mysql]# ls -l

    total 175376

    -rw-r--r-- 1 root root 179403866 Jul 1 03:57 mysql-5.5.25-linux2.6-i686.tar.gz

     

    [root@bspdev mysql]#tar -vxf mysql-5.5.25-linux2.6-i686.tar.gz

    mysql-5.5.25-linux2.6-i686/include/my_config.h

    mysql-5.5.25-linux2.6-i686/include/keycache.h

    mysql-5.5.25-linux2.6-i686/include/m_string.h

    mysql-5.5.25-linux2.6-i686/include/mysql_version.h

    mysql-5.5.25-linux2.6-i686/include/my_alloc.h

    (篇幅原因,省略……

     

    [root@bspdev mysql]# ls -l

    total 4

    drwxr-xr-x 13 root root 4096 Jul 1 04:02 mysql-5.5.25-linux2.6-i686

     

     

    打开目录,可以发现压缩版解压之后,所有的配置文件和执行程序目录。

     

     

    [root@bspdev mysql-5.5.25-linux2.6-i686]# ls -l

    total 76

    drwxr-xr-x 2 root root  4096 Jul 1 04:01 bin

    -rw-r--r-- 1 7161 wheel 17987 May 15 15:46 COPYING

    drwxr-xr-x 4 root root  4096 Jul 1 04:02 data

    drwxr-xr-x 2 root root  4096 Jul 1 04:01 docs

    drwxr-xr-x 3 root root  4096 Jul 1 04:00 include

    -rw-r--r-- 1 7161 wheel 7604 May 15 15:46 INSTALL-BINARY

    drwxr-xr-x 3 root root  4096 Jul 1 04:02 lib

    drwxr-xr-x 4 root root  4096 Jul 1 04:00 man

    drwxr-xr-x 10 root root  4096 Jul 1 04:02 mysql-test

    -rw-r--r-- 1 7161 wheel 2552 May 15 15:46 README

    drwxr-xr-x 2 root root  4096 Jul 1 04:01 scripts

    drwxr-xr-x 27 root root  4096 Jul 1 04:02 share

    drwxr-xr-x 4 root root  4096 Jul 1 04:01 sql-bench

    drwxr-xr-x 2 root root  4096 Jul 1 04:01 support-files

     

    [root@bspdev mysql-5.5.25-linux2.6-i686]# pwd

    /mysql/mysql-5.5.25-linux2.6-i686

     

     

    注意,无论是Windows版还是Linux版,MySQL在运行启动的时候,都需要一个基础配置文件。不同的操作系统拓展名称不一样,大都是my.ini/my.cnf等等。

     

    在目录的support-files中,我们可以找到MySQL提供了一套默认模板,用于配置不同规模的MySQL数据库。

     

     

    [root@bspdev mysql-5.5.25-linux2.6-i686]# cd support-files/

    [root@bspdev support-files]# ls -l

    total 96

    -rwxr-xr-x 1 7161 wheel 1153 May 15 16:46 binary-configure

    -rwxr-xr-x 1 7161 wheel 4528 May 15 16:46 config.huge.ini

    -rwxr-xr-x 1 7161 wheel 2382 May 15 16:46 config.medium.ini

    -rwxr-xr-x 1 7161 wheel 1626 May 15 16:46 config.small.ini

    -rw-r--r-- 1 7161 wheel  773 May 15 15:46 magic

    -rw-r--r-- 1 7161 wheel 4691 May 15 16:46 my-huge.cnf

    -rw-r--r-- 1 7161 wheel 19759 May 15 16:46 my-innodb-heavy-4G.cnf

    -rw-r--r-- 1 7161 wheel 4665 May 15 16:46 my-large.cnf

    -rw-r--r-- 1 7161 wheel 4676 May 15 16:46 my-medium.cnf

    -rw-r--r-- 1 7161 wheel 2840 May 15 16:46 my-small.cnf

    -rwxr-xr-x 1 7161 wheel 1061 May 15 16:46 mysqld_multi.server

    -rwxr-xr-x 1 7161 wheel  839 May 15 16:46 mysql-log-rotate

    -rwxr-xr-x 1 7161 wheel 10650 May 15 16:46 mysql.server

    -rwxr-xr-x 1 7161 wheel 1326 May 15 16:46 ndb-config-2-node.ini

     

    --拷贝模板到指定目录指定名称。

    [root@bspdev support-files]# cp my-huge.cnf /etc/my.cnf

     

     

    标红的几个文件,就是针对不同的系统规模,主要是服务器内存大小来预定义的配置文件。My-huge.cnf一般是应对服务器内存在1-2G,而且是专门作为MySQL服务器使用的场景。这点对于目前的生产系统,不是什么大问题。所以,我们使用这个版作为基础模板,复制为/etc/my.cnf

     

    MySQL配置文件的目录,不同的操作系统有不同的默认选择。对Windows而言,默认是选择%WINDIR%作为优先搜索目录,找寻文件名称为my.ini的文件。当然,我们在mysqld的启动参数defaults-file中,也可以指定该文件的目录名称。

     

    Linux环境下,我们就将其放在/etc/my.cnf就可以了。

     

     

    3、配置文件修改

     

    下面,需要对my.cnf做出简单的修改,使其可以作为启动文件。我们必须添加上MySQL程序文件和数据文件的目录,这样才能够让MySQLd服务器在启动后可以找到相应的路径。

     

     

    [root@bspdev etc]# su - mysql

    [mysql@bspdev ~]$ vi /etc/my.cnf

     

    # Example MySQL config file for very large systems.

    #

    # This is for a large system with memory of 1G-2G where the system runs mainly

    # MySQL.

    #

    # MySQL programs look for option files in a set of

    # locations which depend on the deployment platform.

     

     

    # The MySQL server

    [mysqld]

    basedir=/mysql/mysql-5.5.25-linux2.6-i686

    datadir=/mysql/mysql-5.5.25-linux2.6-i686/data

     

     

    注意,basedirdatadir是通常需要设置的内容。如果没有设置,MySQL会根据操作系统的不同,在默认目录上进行寻找,引起错误。

     

     

    5、初始化数据库

     

     

    Linux版本的压缩版,我们需要手工的创建数据库。在Windows版本中,很多时候是不需要进行这个步骤的。创建的方法也比较简单,就是运行相应的脚本程序。

     

    --在程序目录中。

    [mysql@bspdev mysql-5.5.25-linux2.6-i686]$ scripts/mysql_install_db

    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:

     

    /mysql/mysql-5.5.25-linux2.6-i686/bin/mysqladmin -u root password 'new-password'

    /mysql/mysql-5.5.25-linux2.6-i686/bin/mysqladmin -u root -h bspdev.localdomain password 'new-password'

     

    Alternatively you can run:

    /mysql/mysql-5.5.25-linux2.6-i686/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 /mysql/mysql-5.5.25-linux2.6-i686 ; /mysql/mysql-5.5.25-linux2.6-i686/bin/mysqld_safe &

     

    You can test the MySQL daemon with mysql-test-run.pl

    cd /mysql/mysql-5.5.25-linux2.6-i686/mysql-test ; perl mysql-test-run.pl

     

    Please report any problems with the /mysql/mysql-5.5.25-linux2.6-i686/scripts/mysqlbug script!

     

     

    从输出信息,我们可以看到MySQL提供了一些信息,作为下面工作的参考。

     

    6、启动/关闭测试

    方法1:service mysql/mysqld start/restart/stop

    方法2:相应目录/mysqld_safe 我本地测试是这样的 /data1/software/mysql-5.1.38/scripts/mysqld_safe


  • 相关阅读:
    Django cache (缓存)
    Django CSRF
    Django 中的 Cookie 和 Session
    Django views 中的装饰器
    Ajax 基础
    JavaScript 对象
    Django ORM 操作
    Django 视图
    Django 路由系统
    Django 模版语言
  • 原文地址:https://www.cnblogs.com/pangblog/p/3364656.html
Copyright © 2020-2023  润新知