码迷,mamicode.com
首页 > 数据库 > 详细

部署基于python的web发布环境(第一篇)1:安装nginx、2:安装mysql5.7

时间:2020-02-28 20:23:20      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:mysqlshow   prefix   nes   sla   flag   font   hat   ati   oba   

环境部署1安装nginx

nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站

centos7安装mysql5.7

本次安装采用源码安装,安装版本为mysql-5.7.29

版本nginx 1.15.5,mysql-5.7.29

系统环境centos7.5

关闭selinux 和防火墙firewall

 

一、安装各种依赖环境

yum -y install ncurses-devel gcc-* bzip2-*
yum install openssl-devel openssl
 

  

二、下载cmake

cmake命令 2.8以上 https://cmake.org/download/

 

下载cmake3.6.0,这个版本在GitHub找不到

需要在https://cmake.org里找

wget https://cmake.org/files/v3.6/cmake-3.6.0-rc1.tar.gz

  

如果遇到错误

wget: unable to resolve host address ‘github.com’

  


?

修改/etc/resolv.conf,改变DNS解析地址

vi /etc/resolv.conf 
# Generated by NetworkManager
search lan
nameserver 223.5.5.5
?

  

增加DNS

 

 

三、下载boost

Boost库是一个可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进 程的开发引擎之一 https://www.boost.org/

下载boost,注意选择1.59版本

wget  https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.bz2

  

 

 

四、下载mysql

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

Select Operating System:

选择source code 进行源码安装

Select OS Version:

选择generic linux 通用的linux

选择download

 

 

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29.tar.gz

  

 

五、安装cmake

[root@web01 local]# tar xf cmake-3.6.0-rc1.tar.gz 
[root@web01 local]# cd cmake-3.6.0-rc1
[root@web01 cmake-3.6.0-rc1]# ls
Auxiliary                   configure             Modules
bootstrap                   CONTRIBUTING.rst      Packaging
CMakeCPack.cmake            Copyright.txt         README.rst
CMakeCPackOptions.cmake.in  CTestConfig.cmake     Source
CMakeGraphVizOptions.cmake  CTestCustom.cmake.in  Templates
CMakeLists.txt              DartConfig.cmake      Tests
CMakeLogo.gif               doxygen.config        Utilities
cmake_uninstall.cmake.in    Help
CompileFlags.cmake          Licenses
[root@web01 cmake-3.13.0]# ./configure  开始进行配置
?
...
CMake has bootstrapped.  Now run gmake.
[root@web01 cmake-3.6.0-rc1]#  #完成安装cmake
?
[root@web01 cmake-3.6.0-rc1]# make #进行编译
...
[100%] Linking CXX static library libfoo.a
[100%] Built target foo
[root@web01 cmake-3.6.0-rc1]# #完成编译
?
[root@web01 cmake-3.6.0-rc1]# make install #完成安装

  


?
?

六、安装boost

boost 直接解压用就可以了

[root@web01 usr]# tar -xf boost_1_59_0.tar.bz2 
[root@web01 usr]# mv boost_1_59_0 /usr/local/boost

  

 

七、安装mysql、设置mysql

[root@web01 usr]# tar -xf mysql-5.7.29.tar.gz 
[root@web01 usr]# ls
bin                   etc      lib      local                sbin   tmp
boost_1_59_0.tar.bz2  games    lib64    mysql-5.7.29         share
cmake-3.14.2          include  libexec  mysql-5.7.29.tar.gz  src
[root@web01 usr]# cd mysql-5.7.29
[root@web01 mysql-5.7.29]# ls
BUILD            Doxyfile-perfschema  LICENSE     regex             unittest
client           extra                man         scripts           VERSION
cmake            include              mysql-test  source_downloads  vio
CMakeLists.txt   INSTALL              mysys       sql               win
cmd-line-utils   libbinlogevents      mysys_ssl   sql-common        zlib
config.h.cmake   libbinlogstandalone  packaging   storage
configure.cmake  libmysql             plugin      strings
dbug             libmysqld            rapid       support-files
Docs             libservices          README      testclients
[root@web01 mysql-5.7.29]# 
?
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT=‘Mysqlma‘ -DWITH_BOOST=/usr/local/boost -DSYSCONFDIR=/data/mysqldata/3306 -DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock
?
?
?
?
...
-- Performing Test run_pic_test - Success
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/cmake-3.6.0-rc1
---------------------------------------------
CMake has bootstrapped.  Now run gmake.
[root@web01  mysql-5.7.29]# #完成配置
?
[root@web mysql-5.7.29]# make
?
[root@web mysql-5.7.29]# make install
?
?

  


?

设置mysql

复制启动文件

[root@web mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@web mysql]# chmod 755 /etc/init.d/mysql

  


?
?

设置所有者为mysql

#添加mysql用户
[root@web mysql]# useradd -s /sbin/nologin -r mysql
[root@web mysql]# chown mysql.mysql /usr/local/mysql/ -R
?
?
#mysql的所有者是用户mysql
[root@web mysql]# ll
total 296
drwxr-xr-x  2 mysql mysql   4096 Feb 15 14:31 bin
drwxr-xr-x  2 mysql mysql     55 Feb 15 14:30 docs
drwxr-xr-x  3 mysql mysql   4096 Feb 15 14:30 include
drwxr-xr-x  4 mysql mysql    192 Feb 15 14:31 lib
-rw-r--r--  1 mysql mysql 276202 Dec 18 20:59 LICENSE
drwxr-xr-x  4 mysql mysql     30 Feb 15 14:30 man
drwxr-xr-x 10 mysql mysql   4096 Feb 15 14:31 mysql-test
-rw-r--r--  1 mysql mysql    587 Dec 18 20:59 README
-rw-r--r--  1 mysql mysql    587 Dec 18 20:59 README-test
drwxr-xr-x 28 mysql mysql   4096 Feb 15 14:31 share
drwxr-xr-x  2 mysql mysql     90 Feb 15 14:31 support-files
[root@web mysql]# 
?

  

建立一些链接方便使用

[root@web mysql]# ln -sf /usr/local/mysql/lib/* /usr/lib/
[root@web mysql]# ln -sf /usr/local/mysql/libexec/* /usr/local/libexec
[root@web mysql]# ln -sf /usr/local/mysql/share/man/man1/* /usr/share/man/man1
[root@web mysql]# ln -sf /usr/local/mysql/share/man/man8/* /usr/share/man/man8
ln -s /usr/local/mysql/bin/ /usr/bin
?

  

修改mysql配置文件

[root@web mysql]# vi /etc/my.cnf
?
#增加basedir
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data #修改安装位置
socket=/usr/local/mysql/mysql.sock #修改安装位置
?
#增加
[mysql]
socket=/usr/local/mysql/mysql.sock
?
?
#修改日志放置位置
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
?

  

初始化mysql

/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
?
...
2020-02-15T10:35:12.387256Z 0 [Warning] CA certificate ca.pem is self signed.
2020-02-15T10:35:12.520235Z 1 [Note] A temporary password is generated for root@localhost: Nolrmof#f79D

  

启动mysql

[root@web mysql]# /etc/init.d/mysql start
Starting MySQL. SUCCESS! 
[root@web mysql]# 

  


?

修改mysql的默认密码

[root@web mysql]# cd /usr/local/mysql/bin
[root@web bin]# ls
innochecksum                mysql_config               mysqlshow
lz4_decompress              mysql_config_editor        mysqlslap
myisamchk                   mysqld                     mysql_ssl_rsa_setup
myisam_ftdump               mysqld_multi               mysqltest
myisamlog                   mysqld_safe                mysqltest_embedded
myisampack                  mysqldump                  mysql_tzinfo_to_sql
my_print_defaults           mysqldumpslow              mysql_upgrade
mysql                       mysql_embedded             mysqlxtest
mysqladmin                  mysqlimport                perror
mysqlbinlog                 mysql_install_db           replace
mysqlcheck                  mysql_plugin               resolveip
mysql_client_test           mysqlpump                  resolve_stack_dump
mysql_client_test_embedded  mysql_secure_installation  zlib_decompress
[root@web bin]# ./mysql_secure_installation
?
Securing the MySQL server deployment.
?
Enter password for user root: 
?
Securing the MySQL server deployment.
?
Enter password for user root: 
The ‘validate_password‘ plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
?
Estimated strength of the password: 25 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
#要不要修改成更强的密码,n
 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
?
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
#要不要移除匿名用户
?
Normally, root should only be allowed to connect from
‘localhost‘. This ensures that someone cannot guess at
the root password from the network.
?
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
#要不要禁用远程登录 y
?
By default, MySQL comes with a database named ‘test‘ that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
?
?
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.
#是不是要删除test库,y
?
 - Removing privileges on test database...
Success.
?
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
?
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
#设置是不是要生效
 

 

  

登录mysql

[root@web mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.29 Mysqlma
?
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> 

  


?

 

部署基于python的web发布环境(第一篇)1:安装nginx、2:安装mysql5.7

标签:mysqlshow   prefix   nes   sla   flag   font   hat   ati   oba   

原文地址:https://www.cnblogs.com/Nicholas0707/p/12378669.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!