zoukankan      html  css  js  c++  java
  • Linux下安装MySQL数据库

    在我百撕不得其姐情况下,百度到了一篇亲测有用的文章,如下:

    1.这里我将Mysql安装在/usr/local/mysql目录里面,也可以安装在其他地方;

    mkdir /usr/local/mysql

    2.下载MySQL压缩包

    wget http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz 

    // 由于MySQL运行需要libaio库,所以需要运行以下命令进行安装
    yum install -y libaio
    // 如果上边的命令不行的话 可以使用下边的命令 curl -O -L http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz

    3.解压并复制

    tar -xvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz
    mv mysql-5.7.11-linux-glibc2.5-x86_64/* /usr/local/mysql/

    4.创建data目录

    mkdir /usr/local/mysql/data

    5.创建mysql用户组及其用户

    groupadd mysql
    useradd -r -g mysql mysql

    6.初始化数据

    切换到mysql文件夹下面
    [root@localhost mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 2016-01-20 02:47:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize 2016-01-20 02:47:45 [WARNING] The bootstrap log isn't empty: 2016-01-20 02:47:45 [WARNING] 2016-01-19T18:47:36.732678Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead 2016-01-19T18:47:36.750527Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2016-01-19T18:47:36.750560Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000

    7.复制配置文件到 /etc/my.cnf

    cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y) 

    8.MySQL的服务脚本放到系统服务中

    cp -a ./support-files/mysql.server /etc/init.d/mysqld
    vim编辑etc文件夹下的my.cnf文件
    # These are commonly set, remove the # and set as required.
    basedir = /usr/local/mysql
    datadir = /usr/local/mysql/data
    port = 3306
    # server_id = .....
    socket = /tmp/mysql.sock
    character-set-server = utf8
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 

    9.创建In

    ln -s /usr/local/mysql/bin/mysql  /usr/bin/

    10.启动服务

    service mysqld start 

    11.初始化密码

    mysql5.7会生成一个初始化密码,在root中.mysql_secret文件中。
    [root@localhost ~]# cat /root/.mysql_secret
    # Password set for user 'root@localhost' at 2017-03-16 00:52:34 
    ws;fmT7yh0CM

    12.登录并修改密码

    [root@localhost ~]# mysql -u root -p
    
    alter user root@localhost identified by 'root';
    
    flush privileges;

    13.退出重新登录,完成

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.11 sec)

    ok了


    创建数据库:

    create database abc;

    导入sql文件:

    source /xxx/xxx/xxxx.sql;

    ok!

  • 相关阅读:
    bzoj 2882: 工艺 后缀自动机
    bzoj 2002: 弹飞绵羊 Link-Cut-Tree
    bzoj 3881: [Coci2015]Divljak AC自动机
    bzoj 2553: [BeiJing2011]禁忌 AC自动机+矩阵乘法
    bzoj 3172: [Tjoi2013]单词 fail树
    bzoj 2434: 阿狸的打字机 fail树+离线树状数组
    bzoj 1030: 文本生成器 AC自动机+dp
    SAS FORMAT 逻辑库存储 【输出格式 没有找到或无法加载】解决方法
    PROC UNIVARIATE 简单示例
    SAS ODS GRAPHICS SGPLOT 画图 指存放定路径、名称、指定格式
  • 原文地址:https://www.cnblogs.com/zhangjianbing/p/9040421.html
Copyright © 2011-2022 走看看