• mysql5.5.28在Linux下的安装


    1.       下载mysql

    http://dev.mysql.com/downloads/mysql/ 官网上下载mysql-5.5.28-linux2.6-i686.tar.gz.

    2.       解压

       假如tar包在/home/zdw/software目录下

    #tar -xvf mysql-5.5.28-linux2.6-i686.tar.gz

    3.       移动到/usr/local/mysql

    #mv mysql-5.5.28-linux2.6-i686 /usr/local/

    添加快捷方式mysql指向mysql-5.5.28-linux2.6-i686

    #ln -s mysql-5.5.28-linux2.6-i686/ mysql

    4.       安装依赖的lib包:执行/usr/local/mysql/bin/mysqld,报错

    /usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot               open shared object file: No such file or directory

    使用apt-cache search libaio,找到如下软件源

    libaio-dev - Linux kernel AIO access library - development files

    libaio1 - Linux kernel AIO access library - shared library

    libaio1-dbg - Linux kernel AIO access library - debugging symbols

    使用#apt-get install libaio1 安装

    5.       配置用户,目录

    #groupadd mysql

    #useradd -r -g mysql mysql

    #cd /usr/local/mysql

    #chown -R mysql .

    #chgrp -R mysql .

    6.       初始化mysql

        假如当前目录为/usr/local/mysql

    #scripts/mysql_install_db --user=mysql

    7.       启动mysql

    最简单的启动方式:

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

    默认情况下使用/usr/local/mysql/data作为mysql的数据目录,包括数据库文件,log日志。

    常用的mysql启动参数:

    /usr/local/mysql/bin/mysqld  --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data  --port=3306 --socket=/tmp/mysql.socks

    推荐的启动mysql

    #/usr/local/mysql/support-files/mysql.server start

    启动完成之后用ps -ef |grep mysql 命令查看是否启动

    8.       登录mysql

    #/usr/local/mysql/bin/mysql -u root -p

    默认密码为空

     

    修改root密码

    mysql>use mysql ;
    mysql>update user set password=PASSWORD("123456") where user='root';
    mysql>FLUSH PRIVILEGES;

    9.       关闭mysql

    最简单的方式

    #killall mysqld

    推荐的方式

    #/usr/local/mysql/support-files/mysql.server stop

    使用mysql.server stop关闭mysqld会销毁pid文件,并做容错操作,但是最后也是调用kill命令kill mysql。

     

    关闭mysql,尽量不要用kill -9 mysql_pid或者是killall -9 mysql,否则mysql进程无法做退出处理,就可能会丢失数据,甚至导致表损坏。

     

    10.   浅析mysql.server脚本的启动流程

    mysql.server脚本可以看到在以下脚本调用mysqld_safe这个bash

    $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &

    默认情况下,$bindir/mysqld_safe就是/usr/local/mysql/bin/mysqld_safe这个shell,我的本机的调用参数如下:

    /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/blue-pc.pid

    而mysqld_safe也是一个shell,可以看到在这个脚本在初始化N多变量后,调用

    eval_log_error "$cmd"

    这个shell function最后就是调用

     #echo "Running mysqld: [$cmd]" eval "$cmd"

    在我本机,这个$cmd就是

    /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/blue-pc.err --pid-file=/usr/local/mysql/data/blue-pc.pid

    参考文章:
    http://dev.mysql.com/doc/refman/5.5/en/binary-installation.html
    本文在Ubuntu11.04和Fedora14下测试成功。

     

    root@zwj-virtual-machine1:/usr/local/mysql-5.5.28-linux2.6-i686# scripts/mysql_install_db --user=mysql
    scripts/mysql_install_db: 1: scripts/mysql_install_db: ./bin/my_print_defaults: not found
    Neither host 'zwj-virtual-machine1' nor 'localhost' could be looked up with
    ./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
    root@zwj-virtual-machine1:/usr/local/mysql-5.5.28-linux2.6-i686# scripts/mysql_install_db --user=mysql --force option
    scripts/mysql_install_db: 1: scripts/mysql_install_db: ./bin/my_print_defaults: not found
    Installing MySQL system tables...
    scripts/mysql_install_db: 403: scripts/mysql_install_db: ./bin/mysqld: not found

    Installation of system tables failed! Examine the logs in
    ./data for more information.

    You can try to start the mysqld daemon with:

    shell> ./bin/mysqld --skip-grant &

    and use the command line tool ./bin/mysql
    to connect to the mysql database and look at the grant tables:

    shell> ./bin/mysql -u root mysql
    mysql> show tables

    Try 'mysqld --help' if you have problems with paths. Using --log
    gives you a log in ./data that may be helpful.

    Please consult the MySQL manual section
    'Problems running mysql_install_db', and the manual section that
    describes problems on your OS. Another information source are the
    MySQL email archives available at http://lists.mysql.com/.

    Please check all of the above before mailing us! And remember, if
    you do mail us, you MUST use the ./bin/mysqlbug script!

    root@zwj-virtual-machine1:/usr/local/mysql-5.5.28-linux2.6-i686#

  • 相关阅读:
    java项目启动报Unsupported major.minor version 51.0错
    eclipse启动报错
    使用ftp加IP上传文件
    Java替换中使用正则表达式实现中间模糊匹配
    使用Tomcat安装版启动项目
    java文件流操作
    mybatis所需pom文件内容以及配置文件
    个人写spark小测试
    spark介绍2
    RDD介绍与执行
  • 原文地址:https://www.cnblogs.com/yuhuameng/p/10721016.html
Copyright © 2020-2023  润新知