• 基于通用二进制方式安装Mysql-5.7.24


    之前安装mysql时候比较慢,以下是加速版的

    上传安装包mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

    1、确保系统中有依赖的libaio软件,使用如下命令

    [root@localhost ~]# yum -y install libaio

    [root@localhost ~]# rpm -q libaio
    libaio-0.3.109-13.el7.x86_64

    2、使用wget命令下载mysql-5.7.24软件包

    3、将mysql安装包解压到指定目录,命令如下

    [root@localhost ~]# tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/    //估计用时有点慢

    4、进入到/usr/local/目录

    [root@localhost ~]# cd /usr/local/
    [root@localhost local]# ls
    bin
    etc
    games
    include
    lib
    lib64
    libexec
    mysql-5.7.24-linux-glibc2.12-x86_64
    nginx
    sbin
    share
    src

    5、为mysql安装目录创建软连接

    [root@localhost local]# ln -s mysql-5.7.24-linux-glibc2.12-x86_64/ mysql

    也可以用

    [root@localhost local]# mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql

    6、添加mysql用户和组

    [root@localhost local]# useradd -M -s /sbin/nologin mysql

    7、修改当前目录拥有者为新建的mysql用户,命令如下

    [root@localhost local]# chown -R mysql:mysql /usr/local/mysql/

    8、初始化mysql数据库(建立默认的库和表),命令如下

    [root@localhost local]# cd /usr/local/mysql/

    [root@localhost mysql]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

    porary password is generated for root@localhost: hr%5qe:XrjiI   //记下随机产生的密码

    9、修改mysql配置文件,命令如下

    [root@localhost ~]# vim /etc/my.cnf

       2 datadir=/usr/local/mysql/data
      3 socket=/tmp/mysql.sock

    12 log-error=/usr/local/mysql/data/mysql.log
     13 pid-file=/usr/local/mysql/data/mysql.pid

    保存退出

    10、将mysql服务添加到系统服务中,命令如下

    [root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

    [root@localhost ~]# chmod +x /etc/init.d/mysqld
    [root@localhost ~]# chkconfig --add mysqld

    [root@localhost ~]# systemctl start mysqld

    tcp6       0      0 :::3306                 :::*                    LISTEN      48952/mysqld

    11、将mysql命令添加到系统命令执行路径中,便于使用

    [root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /bin/

    12、使用随机密码登录mysql数据库,命令如下

    [root@localhost ~]# mysql -uroot -p'hr%5qe:XrjiI'

    。。。。。

    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    mysql>
    mysql> exit
    Bye

    13、设置mysql管理用户root的新密码

    [root@localhost ~]# ln -sf /usr/local/mysql/bin/* /bin/
    [root@localhost ~]# mysqladmin -uroot -p'hr%5qe:XrjiI' password 123456
    mysqladmin: [Warning] Using a password on the command line interface can be insecure.
    Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

    [root@localhost ~]# mysql -uroot -p123456

    破译密码:

    在生产环境中,要保证在业务不繁忙的情况下进行破译,因为破译时需要进行关闭数据库

    [root@localhost ~]# systemctl stop mysqld

    [root@localhost ~]# ps aux |grep mysqld
    root      49128  0.0  0.0 112676   984 pts/2    S+   21:43   0:00 grep --color=auto mysqld  //确保没有与之相关的进程

    [root@localhost ~]# mysqld_safe --skip-grant-tables &
    [1] 49145
    [root@localhost ~]# 2019-11-20T13:44:53.569922Z mysqld_safe Logging to '/usr/local/mysql/data/mysql.log'.
    2019-11-20T13:44:53.588675Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data           ///放到后台去启动

    [root@localhost ~]# mysql            //可以不用密码进入
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.24 MySQL Community Server (GPL)
    Copyright (c) 2000, 2018, 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>    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    mysql> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    Database changed
    mysql> show tables;
    +---------------------------+
    | Tables_in_mysql           |
    +---------------------------+
    | columns_priv              |
    | db                        |
    | engine_cost               |
    | event                     |
    | func                      |
    | general_log               |
    | gtid_executed             |
    | help_category             |
    | help_keyword              |
    | help_relation             |
    | help_topic                |
    | innodb_index_stats        |
    | innodb_table_stats        |
    | ndb_binlog_index          |
    | plugin                    |
    | proc                      |
    | procs_priv                |
    | proxies_priv              |
    | server_cost               |
    | servers                   |
    | slave_master_info         |
    | slave_relay_log_info      |
    | slave_worker_info         |
    | slow_log                  |
    | tables_priv               |
    | time_zone                 |
    | time_zone_leap_second     |
    | time_zone_name            |
    | time_zone_transition      |
    | time_zone_transition_type |
    | user                      |
    +---------------------------+
    31 rows in set (0.00 sec)
    mysql> desc user;
    +------------------------+-----------------------------------+------+-----+-----------------------+-------+
    | Field                  | Type                              | Null | Key | Default               | Extra |
    +------------------------+-----------------------------------+------+-----+-----------------------+-------+
    | Host                   | char(60)                          | NO   | PRI |                       |       |
    | User                   | char(32)                          | NO   | PRI |                       |       |
    | Select_priv            | enum('N','Y')                     | NO   |     | N                     |       |
    | Insert_priv            | enum('N','Y')                     | NO   |     | N                     |       |
    | Update_priv            | enum('N','Y')                     | NO   |     | N                     |       |
    | Delete_priv            | enum('N','Y')                     | NO   |     | N                     |       |
    | Create_priv            | enum('N','Y')                     | NO   |     | N                     |       |
    | Drop_priv              | enum('N','Y')                     | NO   |     | N                     |       |
    | Reload_priv            | enum('N','Y')                     | NO   |     | N                     |       |
    | Shutdown_priv          | enum('N','Y')                     | NO   |     | N                     |       |
    | Process_priv           | enum('N','Y')                     | NO   |     | N                     |       |
    | File_priv              | enum('N','Y')                     | NO   |     | N                     |       |
    | Grant_priv             | enum('N','Y')                     | NO   |     | N                     |       |
    | References_priv        | enum('N','Y')                     | NO   |     | N                     |       |
    | Index_priv             | enum('N','Y')                     | NO   |     | N                     |       |
    | Alter_priv             | enum('N','Y')                     | NO   |     | N                     |       |
    | Show_db_priv           | enum('N','Y')                     | NO   |     | N                     |       |
    | Super_priv             | enum('N','Y')                     | NO   |     | N                     |       |
    | Create_tmp_table_priv  | enum('N','Y')                     | NO   |     | N                     |       |
    | Lock_tables_priv       | enum('N','Y')                     | NO   |     | N                     |       |
    | Execute_priv           | enum('N','Y')                     | NO   |     | N                     |       |
    | Repl_slave_priv        | enum('N','Y')                     | NO   |     | N                     |       |
    | Repl_client_priv       | enum('N','Y')                     | NO   |     | N                     |       |
    | Create_view_priv       | enum('N','Y')                     | NO   |     | N                     |       |
    | Show_view_priv         | enum('N','Y')                     | NO   |     | N                     |       |
    | Create_routine_priv    | enum('N','Y')                     | NO   |     | N                     |       |
    | Alter_routine_priv     | enum('N','Y')                     | NO   |     | N                     |       |
    | Create_user_priv       | enum('N','Y')                     | NO   |     | N                     |       |
    | Event_priv             | enum('N','Y')                     | NO   |     | N                     |       |
    | Trigger_priv           | enum('N','Y')                     | NO   |     | N                     |       |
    | Create_tablespace_priv | enum('N','Y')                     | NO   |     | N                     |       |
    | ssl_type               | enum('','ANY','X509','SPECIFIED') | NO   |     |                       |       |
    | ssl_cipher             | blob                              | NO   |     | NULL                  |       |
    | x509_issuer            | blob                              | NO   |     | NULL                  |       |
    | x509_subject           | blob                              | NO   |     | NULL                  |       |
    | max_questions          | int(11) unsigned                  | NO   |     | 0                     |       |
    | max_updates            | int(11) unsigned                  | NO   |     | 0                     |       |
    | max_connections        | int(11) unsigned                  | NO   |     | 0                     |       |
    | max_user_connections   | int(11) unsigned                  | NO   |     | 0                     |       |
    | plugin                 | char(64)                          | NO   |     | mysql_native_password |       |
    | authentication_string  | text                              | YES  |     | NULL                  |       |
    | password_expired       | enum('N','Y')                     | NO   |     | N                     |       |
    | password_last_changed  | timestamp                         | YES  |     | NULL                  |       |
    | password_lifetime      | smallint(5) unsigned              | YES  |     | NULL                  |       |
    | account_locked         | enum('N','Y')                     | NO   |     | N                     |       |
    +------------------------+-----------------------------------+------+-----+-----------------------+-------+
    45 rows in set (0.00 sec)
    mysql> select user,authentication_string from user;
    +---------------+-------------------------------------------+
    | user          | authentication_string                     |
    +---------------+-------------------------------------------+
    | root          | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
    | mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
    +---------------+-------------------------------------------+
    3 rows in set (0.00 sec)
    mysql> update user set authentication_string=PASSWORD('123456') where user='root';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    Rows matched: 1  Changed: 0  Warnings: 1 
    mysql> flush privileges; //刷新数据库
    Query OK, 0 rows affected (0.00 sec)
    mysql> exit
    Bye
    [root@nginx ~]# ps aux|grep mysqld
    root       9993  0.0  0.0 113264  1608 pts/2    S    10:19   0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
    mysql     10135  0.1  9.2 1119996 172652 pts/2  Sl   10:19   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --skip-grant-tables --log-error=/usr/local/mysql/data/mysql.log --pid-file=/usr/local/mysql/data/mysql.pid --socket=/tmp/mysql.sock
    root      10245  0.0  0.0 112676   984 pts/2    R+   10:26   0:00 grep --color=auto mysqld
    [root@nginx ~]# kill -9 9993
    [root@nginx ~]# kill -9 10135
    [1]+  已杀死               mysqld_safe --skip-grant-tables
    [root@nginx ~]# ps aux|grep mysqld
    root      10255  0.0  0.0 112676   984 pts/2    R+   10:27   0:00 grep --color=auto mysqld
    [root@nginx ~]# systemctl start mysqld
    [root@nginx ~]# mysql -uroot -p'123456'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.24 MySQL Community Server (GPL)
    Copyright (c) 2000, 2018, 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> exit
    Bye
    [root@nginx ~]#
    破译完成!!!!!!!!!!!!!!!!!!!!!!!!
                        
  • 相关阅读:
    C++多线程二
    C++多线程一
    定义抽象数据类型
    泛型函数
    关联容器(map):支持高效查找的容器,一种键值对的集合。
    字符串拆成单词的另一种实现
    将字符串拆成单词,并算最长的长度
    重载,排序,集合实例
    程序调用动态链接库中的方法,位图,类
    用bosybox制作文件系统
  • 原文地址:https://www.cnblogs.com/elin989898/p/11901167.html
Copyright © 2020-2023  润新知