确保系统中有依赖的libaio软件

yum -y install libaio

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

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

或导入mysql源码包解压到指定目录

tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

进入/usr/local目录

cd /usr/local/

为mysql安装目录创建软链接或改目录名

mv  mysql-5.7.24-linux-glibc2.12-x86_64/  mysql

添加mysql用户和组

useradd -M -s /sbin/nologin mysql

修改当前目录拥有者为新建的mysql用户

chown -R mysql:mysql /usr/local/mysql

初始化mysql数据库(建立默认的库和表)

/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

  1. --14T07::.921384Z [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2. --14T07::.441772Z [Warning] InnoDB: New log files created, LSN=
  3. --14T07::.519903Z [Warning] InnoDB: Creating foreign key constraint system tables.
  4. --14T07::.590003Z [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: f4ad7ea2-36a0-11ea-ba0a-000c297940e2.
  5. --14T07::.597242Z [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  6. --14T07::.607048Z [Note] A temporary password is generated for root@localhost: ynbk8;Omn*_) --->这是书库登入初始密码

修改mysql配置文件

  1. vim /etc/my.cnf
  2.  
  3. [mysqld]
  4.  
  5. datadir=/usr/local/mysql/data
  6.  
  7. socket=/tmp/mysql.sock
  8.  
  9. [mysqld_safe]
  10.  
  11. log-error=/usr/local/mysql/data/mysql.log
  12.  
  13. pid-file=/usr/local/mysql/data/mysql.pid

将mysqld服务添加到系统服务中

cp mysql/support-files/mysql.server  /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld

systemctl  start  mysqld

netstat  -lnpt | grep :3306

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

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

登入数据库:

[root@localhost local]# mysql -uroot -p"ynbk8;Omn*_)"

mysql>exit

[root@localhost local]# cd
[root@localhost ~]# ln -s /usr/local/mysql/bin/* /bin/
ln: 无法创建符号链接"/bin/mysql": 文件已存在
[root@localhost ~]# ln -sf /usr/local/mysql/bin/* /bin/

数据库外修改密码
[root@localhost ~]# mysqladmin -uroot -p"ynbk8;Omn*_)" password 123
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 -p123
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 5
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

数据库内改密码:

[root@localhost ~]# systemctl stop mysqld

[root@localhost ~]# netstat -anpt | grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 9900/mysqld

[root@localhost ~]# mysqld_safe --skip-grant-tables &
[1] 9933
[root@localhost ~]# 2019-09-23T12:37:13.283220Z mysqld_safe Logging to '/usr/local/mysql/data/mysql.log'.
2019-09-23T12:37:13.328538Z 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> show databases;                          //查看有哪儿些数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |                                                          //用的是mysql
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 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 |                                                                     //用的是user(用户)
+---------------------------+ 
31 rows in set (0.00 sec)

mysql> desc use;                                                  //有哪儿些列
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'use' at line 1
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从from
+---------------+-------------------------------------------+ 
| user | authentication_string |
+---------------+-------------------------------------------+
| root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+---------------+-------------------------------------------+
3 rows in set (0.01 sec)

mysql> update user set authentication_string=PASSWORD('123456') where user='root';                //更新user,authentication_string,用password来加密
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1

mysql> flush privileges;                                                                           //刷新授权表
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

[root@localhost ~]# mysql -uroot -p123456
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 3
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

修改字符集为utf-8

[mysqld]
 
character_set_server=utf8

[root@localhost ~]# systemctl restart mysqld

基于通用二进制方式安装MySQL-5.7.24(比源码安装MySQL快许多)及破密码的更多相关文章

  1. redhat7.4安装git(按照官网从源码安装)

    按照官方文档建议使用源码安装 1.为什么不用yum安装 yum安装确实简单,只用一行命令就可以了,但是yum安装的版本太低. //安装前使用info查看git版本信息等 yum info git yu ...

  2. mysql 5.6.23的源码安装

    http://634871.blog.51cto.com/624871/1325914 首先删除系统自带的mysql rpm -qa | grep mysql   rpm -e mysql   //普 ...

  3. Linux下MySQL、Apache、PHP源码安装全程实录(CentOS 6.4)

    转自http://www.zjmainstay.cn/lamp-config 本文记录了我自己配置LAMP的全过程,借此记录一下,同时希望能够帮助一下需要帮助的LINUX新人,跟我一起学习,一起进步. ...

  4. linux 中的./configuration --prefix=安装路径 的用法(指定源码安装方式的安装路基)

    源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(make install). Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./con ...

  5. Mysql依赖库Boost的源码安装,linux下boost库的安装

      boost‘准标准库’安装过程.安装的是boost_1_60_0. (1)首先去下载最新的boost代码包,网址www.boost.org. (2)进入到自己的目录,解压: bzip2 -d bo ...

  6. Linux源码安装软件

    Linux环境下 源码编译安装软件 ==== 1. 下载,步骤略 ==== 2. 验证,部分官方下载同时提供签名,MD5,sha1,sha256等校验信息. $ gpg --verify gnupg- ...

  7. Python并发编程-redis-3.0.5 源码安装

    1.简介 Remote Dictionary Server(Redis)是一个基于 key-value 键值对的持久化数据库存储系统.redis 和 Memcached 缓存服务很像,但它支持存储的 ...

  8. 源码安装和配置zabbix 3.0 LST

    Zabbix是什么 Zabbix 是由Alexei Vladishev创建,目前由Zabbix SIA在持续开发和支持. Zabbix 是一个企业级的分布式开源监控方案. Zabbix是一款能够监控各 ...

  9. centos上源码安装clang 3.8

    之前想在centos系统上安装clang 3.6版本,由于yum上版本太低,想通过源码编译安装.按照网上说的源码安装步骤,下好llvm.clang.clang-tools-extra和compiler ...

随机推荐

  1. 一些 NuGet 程序包是使用不同于当前目标框架的目标框架安装的,可能需要重新安装

    如果 NuGet 检测到包受到重定向或升级项目的影响,它会将 packages.config 中的 requireReinstallation="true" 属性添加到所有受影响的 ...

  2. 移动端CSS重置

    移动端 CSS Reset 该怎么写 为了应对各大浏览器厂商对浏览器默认样式的不统一处理,我们往往会进行一个 css reset 操作,由于没有标准而且受个人偏好影响,每个公司实现的都不尽相同.关于 ...

  3. JAVA中fail-fast机制

    在JDK的Collection中我们时常会看到类似于这样的话: 例如,ArrayList: 注意,迭代器的快速失败行为无法得到保证,因为一般来说,不可能对是否出现不同步并发修改做出任何硬性保证.快速失 ...

  4. 详解多线程MT和多线程MD的区别

    这段时间司在招实习生,而不管是远程的电话面试或者是实际现场面试中领导都喜欢问你这个问题,但是可惜的是能很好答上来的人很少.后来发现不管是应届的实习生,甚至有些实际参加工作几年的人也未必真的了解这个问题 ...

  5. 设置datagridview 单个单元格的背景色

    方法一: private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e){DataG ...

  6. Windows下MD5校验

    参考博客:https://www.cnblogs.com/liubinghong/p/9299276.html 参考博客:https://www.jianshu.com/p/1e1d56552e03 ...

  7. JSP技术(三)

    JSP指令 指令是JSP语法元素的第一种类型.它们指示JSP转换器如何翻译JSP页面为Servlet.JSP定义了多个指令,但只有page和include最重要.而taglib.tag.attribu ...

  8. 20200227英语上课笔记 about advantage and disadvantage

    Hello and welcome to class! Remember to keep your microphone off when you are not speaking Pronuncia ...

  9. Python类属性和类方法

    01. 类的结构 1.1 术语 —— 实例 使用面相对象开发,第 1 步 是设计 类 使用 类名() 创建对象,创建对象 的动作有两步: 1) 在内存中为对象 分配空间 2) 调用初始化方法 __in ...

  10. 【Python爬虫程序】抓取MM131美女图片,并将这些图片下载到本地指定文件夹。

    一.项目名称 抓取MM131美女写真图片,并将这些图片下载到本地指定文件夹. 共有6种类型的美女图片: 性感美女 清纯美眉 美女校花 性感车模 旗袍美女 明星写真 抓取后的效果图如下,每个图集是一个独 ...