MySQL安装部署

1、简述MySQL体系结构。

客户层
客户层:进行相关的连接处理、权限控制、安全处理等操作
服务层
服务层负责与客户层进行连接处理、处理以及执行SQL语句等,主要包含连接器、查询缓存、优化器、执行器、存储引擎。触发器、视图等也在这一层
存储引擎层
存储引擎层负责对数据的存储和提取,常见的存储引擎有InnoDB、MyISAM、Memory等,在MySQL5.5之后,MySQL默认的存储引擎就是InnoDB,InnoDB默认使用的索引结构就是B+树,上面的服务层就是通过API接口与存储引擎层进行交互的
数据层
数据层系主要包括MySQL中存储数据的底层文件,与上层的存储引擎进行交互,是文件的物理存储层。其存储的文件主要有:日志文件、数据文件、配置文件、MySQL的进行pid文件和socket文件等。

2、安装部署MySQL。(使用yum以及通用二进制方式)。

yum 离线下载

首先下载mysql5.7包

用xftp7

[root@localhost ~]# history 
    1  ls
    2  mkdir mysql
    3  cd mysql
    4  tar xf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar -C mysql
    5  cd
    6  tar xf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar -C mysql
    7  ls
    8  cd mysql
    9  ls
   10  yum localinstall -y mysql-community-server-5.7.18-1.el7.x86_64.rpm mysql-community-client-5.7.18-1.el7.x86_64.rpm mysql-community-common-5.7.18-1.el7.x86_64.rpm mysql-community-libs-5.7.18-1.el7.x86_64.rpm
   11  rpm -e mariadb-libs postfix
   12  yum localinstall -y mysql-community-server-5.7.18-1.el7.x86_64.rpm mysql-community-client-5.7.18-1.el7.x86_64.rpm mysql-community-common-5.7.18-1.el7.x86_64.rpm mysql-community-libs-5.7.18-1.el7.x86_64.rpm
   13  cd
   14  mysql -uroot -p
   15  mysql> show databases
   16  mysql -uroot -p
   17  system start mysqld
   18  systemctl start mysqld
   19  awk '/temporary password/ {print $NF}' /var/log/mysqld.log
   20  mysql -uroot -p
   21  history 

成功启动mysql

[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# awk '/temporary password/ {print $NF}' /var/log/mysqld.log
51V?=km2k6g3
[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18

Copyright (c) 2000, 2017, 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> alter user root@localhost identified by 'RedHat@123';
Query OK, 0 rows affected (0.01 sec)

mysql> ^C
mysql> \q

二进制方式

    1  ll mysql-5.7.14-linux-glibc2.5-x86_64.tar 
    2  groupadd -r mysql
    3  useradd mysql -r -g mysql -c "MySQL Server" -s /bin/false
    4  tar xf mysql-5.7.14-linux-glibc2.5-x86_64.tar -C /usr/local
    5  tar xf /usr/local/mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
    6  ln -sv /usr/local/mysql-5.7.14-linux-glibc2.5-x86_64 /usr/local/mysql
    7  /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
    8  cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
    9  vim /etc/my.cnf
   10  yum install wget unzip bash-completion tree vim lrzsz net-tools -y
   11  vim /etc/my.cnf
   12  cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
   13  chkconfig --add mysqld
   14  chkconfig mysqld on
   15  /usr/local/mysql/bin/mysqld_safe --user=mysql &
   16   
   17  /usr/local/mysql/bin/mysql -uroot -p
   18  /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
   19  awk '/temporary password/ {print $NF}' /var/log/mysqld.log
   20  /usr/local/mysql/bin/mysql -uroot -p
   21  /usr/local/mysql/bin/mysqld_safe --user=mysql &
   22  vim /etc/profile.d/mysql.sh
   23  echo $PATH
   24  vim /etc/profile.d/mysql.sh
   25  source /etc/profile.d/mysql.sh 
   26  mysql -uroot -p
   27  history 
mysql> alter user root@localhost identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

临时密码

最终呈现

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值