美文网首页
Mysql-01. Mysql 5.7.15 for linux

Mysql-01. Mysql 5.7.15 for linux

作者: 程序员_超 | 来源:发表于2018-02-09 20:18 被阅读0次
    1. 上传安装包:mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz 到 /usr/local/
    [root@wch02 local]# pwd
    /usr/local
    [root@wch02 local]# ll
    总用量 626564
    drwxr-xr-x. 2 root root      4096 9月  23 2011 bin
    drwxr-xr-x. 2 root root      4096 9月  23 2011 etc
    drwxr-xr-x. 2 root root      4096 9月  23 2011 games
    drwxr-xr-x. 2 root root      4096 9月  23 2011 include
    drwxr-xr-x. 2 root root      4096 9月  23 2011 lib
    drwxr-xr-x. 2 root root      4096 9月  23 2011 lib64
    drwxr-xr-x. 2 root root      4096 9月  23 2011 libexec
    -rwxr-x---. 1 root root 641556368 10月  8 13:41 mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz
    drwxr-xr-x. 2 root root      4096 9月  23 2011 sbin
    drwxr-xr-x. 5 root root      4096 10月  8 07:37 share
    drwxr-xr-x. 2 root root      4096 9月  23 2011 src
    
    1. 解压;重命名
    # 解压,得到 mysql-5.7.15-linux-glibc2.5-x86_64文件夹
    [root@wch02 local]# tar -zxvf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz 
    
    # 查看
    [root@wch02 local]# ll
    总用量 626568
    drwxr-xr-x. 2 root root      4096 9月  23 2011 bin
    drwxr-xr-x. 2 root root      4096 9月  23 2011 etc
    drwxr-xr-x. 2 root root      4096 9月  23 2011 games
    drwxr-xr-x. 2 root root      4096 9月  23 2011 include
    drwxr-xr-x. 2 root root      4096 9月  23 2011 lib
    drwxr-xr-x. 2 root root      4096 9月  23 2011 lib64
    drwxr-xr-x. 2 root root      4096 9月  23 2011 libexec
    drwxr-xr-x. 9 root root      4096 10月  8 13:46 mysql-5.7.15-linux-glibc2.5-x86_64
    -rwxr-x---. 1 root root 641556368 10月  8 13:41 mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz
    drwxr-xr-x. 2 root root      4096 9月  23 2011 sbin
    drwxr-xr-x. 5 root root      4096 10月  8 07:37 share
    drwxr-xr-x. 2 root root      4096 9月  23 2011 src
    
    # 重命名文件夹mysql-5.7.15-linux-glibc2.5-x86_64 为 mysql
    [root@wch02 local]# mv mysql-5.7.15-linux-glibc2.5-x86_64 mysql
    [root@wch02 local]# ll
    总用量 626568
    drwxr-xr-x. 2 root root      4096 9月  23 2011 bin
    drwxr-xr-x. 2 root root      4096 9月  23 2011 etc
    drwxr-xr-x. 2 root root      4096 9月  23 2011 games
    drwxr-xr-x. 2 root root      4096 9月  23 2011 include
    drwxr-xr-x. 2 root root      4096 9月  23 2011 lib
    drwxr-xr-x. 2 root root      4096 9月  23 2011 lib64
    drwxr-xr-x. 2 root root      4096 9月  23 2011 libexec
    drwxr-xr-x. 9 root root      4096 10月  8 13:46 mysql
    -rwxr-x---. 1 root root 641556368 10月  8 13:41 mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz
    drwxr-xr-x. 2 root root      4096 9月  23 2011 sbin
    drwxr-xr-x. 5 root root      4096 10月  8 07:37 share
    drwxr-xr-x. 2 root root      4096 9月  23 2011 src
    [root@wch02 local]# ls
    bin  games    lib    libexec  mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz  share
    etc  include  lib64  mysql    sbin                                       src
    
    
    1. 创建数据仓库目录
    [root@wch02 local]# mkdir /data/
    [root@wch02 local]# mkdir /data/mysql
    
    1. 新建mysql用户、组及目录
    [root@wch02 local]# groupadd mysql
    [root@wch02 local]# useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql 
    
    1. 改变目录属有者
    [root@wch02 local]# cd /usr/local/mysql
    [root@wch02 mysql]# pwd
    /usr/local/mysql
    [root@wch02 mysql]# chown -R mysql .
    [root@wch02 mysql]# chgrp -R mysql .
    [root@wch02 mysql]# ll
    总用量 52
    drwxr-xr-x.  2 mysql mysql  4096 10月  8 13:46 bin
    -rw-r--r--.  1 mysql mysql 17987 8月  25 19:52 COPYING
    drwxr-xr-x.  2 mysql mysql  4096 10月  8 13:46 docs
    drwxr-xr-x.  3 mysql mysql  4096 10月  8 13:45 include
    drwxr-xr-x.  5 mysql mysql  4096 10月  8 13:46 lib
    drwxr-xr-x.  4 mysql mysql  4096 10月  8 13:46 man
    -rw-r--r--.  1 mysql mysql  2478 8月  25 19:52 README
    drwxr-xr-x. 28 mysql mysql  4096 10月  8 13:46 share
    drwxr-xr-x.  2 mysql mysql  4096 10月  8 13:46 support-files
    [root@wch02 mysql]#
    
    1. 配置参数,注意临时密码
    [root@wch02 mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
    2016-10-08T06:15:03.864310Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Pleaseuse -explicit_defaults_for_timestamp server option (see documentation for more details).
    2016-10-08T06:15:04.749702Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2016-10-08T06:15:04.870206Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2016-10-08T06:15:04.958445Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 8dd6e28a-8d1e-11e6-8f75-080027a41e5c.
    2016-10-08T06:15:04.960409Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2016-10-08T06:15:04.968720Z 1 [Note] A temporary password is generated for root@localhost: MRawrclOy6>C '得到临时密码:MRawrclOy6>C'
    
    [root@wch02 mysql]# bin/mysql_ssl_rsa_setup  --datadir=/data/mysql
    Generating a 2048 bit RSA private key
    .............+++
    .............................+++
    writing new private key to 'ca-key.pem'
    -----
    Generating a 2048 bit RSA private key
    ..........................................................................+++
    ...................................................................................................................+++
    writing new private key to 'server-key.pem'
    -----
    Generating a 2048 bit RSA private key
    .......................................................+++
    ...................................+++
    writing new private key to 'client-key.pem'
    -----
    
    
    1. 修改系统配置文件
    [root@wch02 support-files]# cp my-default.cnf /etc/my.cnf
    cp:是否覆盖"/etc/my.cnf"? y
    [root@wch02 support-files]# cp mysql.server /etc/init.d/mysql
    [root@wch02 support-files]# vim /etc/init.d/mysql #修改以下内容,必须该,否则有可能造成数据库服务启动报错
    basedir=/usr/local/mysql
    datadir=/data/mysql
    
    1. 登陆,测试
    [root@wch02 support-files]# cd /usr/local/mysql
    [root@wch02 mysql]# mkdir data
    [root@wch02 mysql]# cd bin
    [root@wch02 bin]# ./mysqld_safe --user=mysql &
    [root@wch02 bin]# service mysql restart
    [root@wch02 bin]# ./mysql -u root -p 
    Enter password:     '此时登陆所用的密码是由第6步产生的临时密码'
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.7.15
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> SET PASSWORD = PASSWORD('112233');
    Query OK, 0 rows affected, 1 warning (0.01 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql>exit #退出,重新用新密码登陆
    Bye
    [root@wch02 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.7.15 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    
    mysql>
    
    1. 将mysql命令加入到环境变量中
    PATH=$PATH:/usr/local/mysql/bin
    export PATH
    将以上两行字符串添加到/etc/profile末尾。
    [root@wch02 bin]# vim /etc/profile
    
    [root@wch02 bin]# source /etc/profile
    [root@wch02 bin]# mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 4
    Server version: 5.7.15 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    
    mysql>
    
    1. 至此,整个安装过程结束。

    相关文章

      网友评论

          本文标题:Mysql-01. Mysql 5.7.15 for linux

          本文链接:https://www.haomeiwen.com/subject/msivzxtx.html