开源数据库MySQL DBA运维实战

开源数据库MySQL DBA运维实战

1、数据库系统结构

  1. 数据库系统 DBS:

    A.数据库管理系统(DataBase Management System, DBMS): (面试题) SQL(RDS托管型关系型数据库)关系型数据库

  • ORACLE

  • Oracle MySQL

  • DB2(IBM)

  • SQL-server(MS)

  • Mysql

  • MariaDB

  • Percona server(taobao)

    B.DBA:工程师

  1. SQL语言(结构化查询语言)
  • DQL语句 数据库查询语言: 查询数据 SELECT
  1. 数据访问技术
  • A. ODBC PHP <.php>
  • B. JDBC JAVA <.jsp>
  • 3.ASP.NET<c#>

2、RPM包部署mysql

  1. 关闭防火墙
systemctl stop  firewalld
systemctl enable  firewalld
setenforce 0
vim    /etc/selinux/config     SELINUX=disabled  --开机禁用selinux
  1. 访问国内mysql镜像站(中国科技大学开源镜像站)
  1. 下载软件包
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-server-5.7.25-1.el7.x86_64.rpm

wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.25-1.el7.x86_64.rpm

wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.25-1.el7.x86_64.rpm

wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.25-1.el7.x86_64.rpm
  1. 安装相关软件
yum  install  -y   net-tools.x86_64    libaio.x86_64    perl.x86_64
  1. 安装Mysql服务器
yum remove -y mariadb-libs.x86_64

yum install -y mysql-community*(一般会和mariadb产生冲突,需要卸载)
  1. 启动Mysql服务器
systemctl start mysqld

systemctl enable mysqld

systemctl status mysqld
  1. 查询Mysql服务器默认密码
grep ‘password‘ /var/log/mysqld.log 
  1. 修改Mysql服务器密码
mysqladmin   -uroot    -p‘es,W;ya(K1Th‘    password    ‘QianFeng@123‘
  1. 登录Mysql系统
mysql      -uroot         -p‘QianFeng@123‘

show   databases;

3、源码包部署mysql

  1. 编译环境
yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
  1. 准备源码包
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
tar xvf mysql-5.7.19.tar.gz(先得到软件包)
cd mysql-5.7.19
mv ../boost_1_59_0.tar.gz  .
tar xf  boost_1_59_0.tar.gz(先得到软件包)
  1. 配置
cmake . -DWITH_BOOST=boost_1_59_0/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DINSTALL_MANDIR=/usr/share/man -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
  1. 编译
make
  1. 安装
make install
  1. 初始化
cd /usr/local/mysql

mkdir mysql-files

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

/usr/local/mysql/bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data

mv /etc/my.cnf  ~
vim /etc/my.cnf

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
  1. 开机启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

service mysqld start

ps aux |grep mysqld
  1. 登录
/usr/local/mysql/bin/mysql -u root -p‘x/dwiQ2<l:hb‘

/usr/local/mysql/bin/mysqladmin -u root -p ‘x/dwiQ2<l:hb‘ password ‘QinFeng@123‘

show databases; 

开源数据库MySQL DBA运维实战

上一篇:IntelliJ IDEA 2019.1 x64连接MySQL5.7异常及解决办法


下一篇:项目第二天