LNMP项目部署(1)-数据库部署

LNMP项目实战:
L:Linux(centos 7.6) http://mirrors.cqu.edu.cn/CentOS/7.6.1810/isos/x86_64/
N:Nginx(1.12.2) https://nginx.org/en/download.html
M:MySQL(5.6.43) https://dev.mysql.com/downloads/mysql/5.6.html#downloads
P:PHP(7.2.15) http://php.net/downloads.php
Worldpress(5.0.3):https://cn.wordpress.org/download/

部署规划:
192.168.39.7:Nginx php-fpm 运行web服务
192.168.39.10:NFS存储服务器,存储上传的图片
192.168.39.101:运行MySQL数据库

LNMP项目部署(1)-数据库部署_第1张图片

一、二进制部署MySQL数据库:

1、安装依赖的包

[root@centos7 ~]# yum install vim gcc gcc-c++ wget autoconf net-tools lrzsz iotop lsof iotop bash-completion curl policycoreutils openssh-server openssh-clients postfix -y

2、下载并解压mysql二进制程序

[root@centos7 ~]# cd /usr/local/src/ 
[root@centos7 ~]# tar xf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz
#软连接
[root@centos7 ~]# ln -sv /usr/local/src/mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/mysql

#创建数据目录和用户
[root@centos7 ~]# useradd mysql -s /sbin/nologin 
[root@centos7 ~]# mkdir -pv /data/mysql /var/lib/mysql
[root@centos7 ~]# chown -R mysql.mysql /data /var/lib/mysql -R
#生成数据目录
[root@centos7 ~]/usr/local/mysql/scripts/mysql_install_db --user=mysql -- datadir=/data/mysql --basedir=/usr/local/mysql
[root@centos7 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 
[root@centos7 ~]# chmod a+x /etc/init.d/mysqld

3、编辑配置文件: 注意数据存放目录,要与上面的一致

[mysqld]
socket=/data/mysql/mysql.sock
user=mysql
symbolic-links=0
datadir=/data/mysql
innodb_file_per_table=1
max_connections=10000
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/tmp/mysql.sock

4、创建数据库并授权:

[root@centos7 mysql]#  /etc/init.d/mysqld start
Starting MySQL..... SUCCESS!
[root@centos7 mysql]# ln -sv /data/mysql/mysql.sock /var/lib/mysql/mysql.sock
[root@centos7 mysql]#/usr/local/mysql/bin/mysql
mysql> create database wordpress;

mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"192.168.39.%" IDENTIFIED BY "123456";
Query OK, 0 rows affected (0.03 sec)

mysql>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

5、验证MySQL账户权限:

在WordPress服务器使用授权的MySQL账户远程登录测试权限
mysql -uwordpress -h192.168.39.101 -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 4
Server version: 5.6.46 MySQL Community Server (GPL)
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,linux,nginx,数据库)