• 1. mysql安装


    1. rpm包安装

      [root@server2 Packages]# ls mysql*

      mysql-5.1.61-4.el6.i686.rpm                                mysql-devel-5.1.61-4.el6.i686.rpm

      mysql-bench-5.1.61-4.el6.i686.rpm                   mysql-libs-5.1.61-4.el6.i686.rpm

      mysql-connector-java-5.1.17-6.el6.noarch.rpm    mysql-server-5.1.61-4.el6.i686.rpm

      mysql-connector-odbc-5.1.5r1144-7.el6.i686.rpm  mysql-test-5.1.61-4.el6.i686.rpm

      mysql-5.1 客户端包

      mysql-server  服务器端包

      mysql-libs 系统默认装上该包,里面包含了库文件     mysql-devel包包含一些 .h的头文件,做c语言等开发时用装上

      启动mysql

    service mysqld start

       查看运行进程

    [root@server2 ~]# ps aux | grep "mysql"

    root      2440  0.0  0.2   6720  1412 pts/0    S    20:15   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql

    mysql   2529  6.7  3.1 125156 16056 pts/0    Sl   20:15   0:01 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

     

    [root@server2 ~]# cat /etc/my.cnf

    [mysqld]

    datadir=/var/lib/mysql                                                            //数据库数据目录

    socket=/var/lib/mysql/mysql.sock                                    //sock文件位置,服务启动一定会有,它是本地连接的通道

    user=mysql                                                                                   //执行用户,这样安全性高

    # Disabling symbolic-links is recommended to prevent assorted security risks

    symbolic-links=0

     

    [mysqld_safe]

    log-error=/var/log/mysqld.log                                           //错误日志

    pid-file=/var/run/mysqld/mysqld.pid                             //进程ID号,启动一定存在

     

      登录查看

    [root@server2 ~]# mysql

    mysql> show databases;

    +--------------------+

    | Database           |

    +--------------------+

    | information_schema |

    | mysql              |

    | test               |

    +--------------------+

    mysql> use mysql;

    mysql> show tables;

    +---------------------------+

    | Tables_in_mysql           |

    +---------------------------+

    | columns_priv              |

               ………...

    | user                      |

    +---------------------------+

    23 rows in set (0.00 sec)

    mysql> select user,password,host from user;

    +------+----------+----------------+

    | user | password | host           |

    +------+----------+----------------+

    | root |          | localhost      |                     默认mysql只能本地登录,一般可以把后面几个登录方式删除,更安全

    | root |          | server2.cc.com |                内置root用户登录(非系统root

    | root |          | 127.0.0.1      |

    |      |          | localhost      |                         匿名用户登录

    |      |          | server2.cc.com |

    +------+----------+----------------+


     2.源码包安装

    编译环境:make,gcc,gcc-c++,cmake,ncurses-devel

    用户: useradd   mysql   -u  27   -g   mysql    -M   -s  /sbin/nologin 

    cmake

    -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql56

    -DMYSQL_DATADIR:PATH=/database

    -DWITH_DEBUG:BOOL=on

    -DWITH_EXTRA_CHARSET:STRING=all

    -DWITH_INNOBASE_STORAGE_ENGINE:BOOL=on

    -DWITH_PARTITION_STORAGE_ENGINE:BOOL=on

    make && make install

     

    cat << END >/usr/local/mysql56/etc/my.cnf

    [mysqld]

    basedir=/usr/local/mysql56

    datadir=/database

    socket=/var/run/mysqld/mysql56.sock

    pid-file=/var/run/mysqld/mysql56.pid

    user=mysql

    port=3307

     

    [mysqld_safe]

    log-error=/var/log/mysqld/mysql56-error.log

    END

    chown -R mysql:mysql /usr/local/mysql56 /database/ /var/run/mysqld/ /var/log/mysqld/

    初始化:

    ./mysql_install_db    --basedir=/usr/local/mysql56/  --datadir=/database/   --user=mysql

    启动脚本:

    cp -a /usr/local/mysql56/support-files/mysql.server         /etc/rc.d/init.d/mysql56

    sed -i  '/conf=/c conf=/usr/local/mysql56/etc/my.cnf'     /etc/rc.d/init.d/mysql56

    service  mysql56 start


    3. 二进制包

    只需解压相应的包到指定的位置,然后按照源码包的步骤修改,注意socket,pid名称不同端口不同

    优点:方便,绿色。这三种安装方式中,第二种实际生产中用得最多。

     

    4.mysql数据库结构

    mysql> show databases;

    +--------------------+

    | Database           |

    +--------------------+

    | information_schema |                       //记录系统所有表字段的信息

    | mysql              |                                   //系统数据库,其中mysql.user表保存用户信息

    | performance_schema |

    | test               |

    +--------------------+

    information_schema

    table_schema:   库名

    table_name:    表名

    column_name:  字段名





  • 相关阅读:
    判断某个目录下半小时内是否有新文件
    centos 多路径下挂载磁盘目录
    rac多路径下添加lun
    FFmpeg笔记
    FFmpeg报错大全
    Eclipse 安装C语言开发环境
    乱码
    FreeSql提示“【主库】状态不可用,等待后台检查程序恢复方可使用。”错误
    JetBrains Rider安装说明
    博客园终于可以使用了
  • 原文地址:https://www.cnblogs.com/51runsky/p/544e95134df5842be0d62a61d458ade2.html
Copyright © 2020-2023  润新知