MySQL数据库部署

MySQL数据库部署

MySQL数据库是一个关系型数据库管理系统,属Oracle旗下的产品,MySQL是最流行的关系型数据库管理系统之一;MySQL是一种关系型数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有的数据放在一个大仓库,这样增加了速度并提高了灵活性。
MySQL使用的SQL语言是用于访问数据库的最标准化的语言,MySQL采用了双授权政策,分为社区版和商业版。

数据库系统DBS
关系型数据库:Oracle、DB2、MySQL、Microsoft SQL Server、Microsoft Access
非关系型数据库NoSQL:Redis、MongoDB、Memcache

MySQL的安装(yum安装)

关闭防火墙和selinux

[root@mysql ~]# sed -ri s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
[root@mysql ~]# systemctl stop firewalld && systemctl disable firewalld

安装所需要的软件包

[root@mysql ~]# yum -y groupinstall "Development Tools"
[root@mysql ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@mysql ~]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm
warning: mysql80-community-release-el7-1.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-1  ################################# [100%]

修改MySQL的yum文件
[root@mysql ~]# vim /etc/yum.repos.d/mysql-community.repo
把安装5.7的源打开, 关闭安装8.0的源
安装MySQL并启动
[root@mysql ~]# yum -y install mysql-community-server
[root@mysql ~]# systemctl start mysqld && systemctl enable mysqld

登录数据库

[root@mysql~]# grep "password" /var/log/mysqld.log 
2020-04-13T10:37:15.349234Z 1 [Note] A temporary password is generated for root@localhost: lA5wfrfkh!QW
[root@mysql ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29

Copyright (c) 2000, 2020, 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

扩展

MySQL的几个重要目录

数据库目录: /var/lib/mysql/

配置文件: /usr/share /mysql(mysql.server命令及配置文件)

相关命令: /usr/bin(mysqladmin mysqldump等命令)

启动脚本: /etc/rc.d/init.d/(启动脚本文件mysql的目录)

MySQL部署(源码安装)

安装所需要的依赖及MySQL包

$ yum -y update
$ yum -y groupinstall "Development Tools"
$ yum -y install ncurses ncurses-devel bison libgcrypt perl make cmake
$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.24.tar.gz


添加MySQL进程的用户mysql
[root@mysql_source ~]# groupadd mysql
[root@mysql_source ~]# useradd -M -g mysql -s /sbin/nologin mysql


##在系统中添加自定义mysql数据库目录及其他必要目录
[root@mysql_source ~]# mkdir -p /usr/local/mysqld/{data,mysql,log,tmp}
[root@mysql_source ~]# chown -R mysql:mysql /usr/local/mysqld/*

##将mysql-boost-5.7.24.tar.gz解压到当前目录,并执行部署操作
[root@mysql_source ~]# tar xf mysql-boost-5.7.24.tar.gz
[root@mysql_source ~]# cd mysql-5.7.24
[root@mysql_source mysql-5.7.24]# 
$ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysqld/mysql \
-DMYSQL_DATADIR=/usr/local/mysqld/data \
-DWITH_BOOST=/opt/mysql-5.7.26/boost \

......
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.7.24
[root@mysql_source mysql-5.7.24]# echo $?
0
[root@mysql_source mysql-5.7.24]# make -j `lscpu | awk 'NR==4{ print $2 }'`

......
[100%] Built target udf_example
[root@mysql_source mysql-5.7.24]# echo $?
0
[root@mysql_source mysql-5.7.24]# make install

......
-- Installing: /usr/local/mysqld/mysql/support-files/mysql.server
[root@mysql_source mysql-5.7.24]# echo $?
0
[root@mysql_source mysql-5.7.24]#
Congratulations Complete!

部署完成

猜你喜欢

转载自blog.csdn.net/weixin_45641605/article/details/105494642