前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >干货分享!!!

干货分享!!!

作者头像
Hunter@Miracle
发布2022-08-26 15:18:07
2380
发布2022-08-26 15:18:07
举报
文章被收录于专栏:程序猿香蕉

安装mysql

查看是否安装mysql

代码语言:javascript
复制
rpm -qa | grep mysql

如果你系统有安装,那可以选择进行卸载:

代码语言:javascript
复制
rpm -e mysql  // 普通删除模式
rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

下载mysql启动程序

代码语言:javascript
复制
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

使用yum进行安装

代码语言:javascript
复制
rpm -ivh mysql-community-release-el7-5.noarch.rpm

更新yum

代码语言:javascript
复制
yum update

使用yum命令安装mysql

代码语言:javascript
复制
yum install mysql-server

设置权限

代码语言:javascript
复制
chown -R mysql:mysql /var/lib/mysql/

初始化mysql

代码语言:javascript
复制
mysqld --initialize

启动mysql

代码语言:javascript
复制
systemctl start mysqld

查看mysql运行状态

代码语言:javascript
复制
systemctl status mysqld

修改/etc/my.cnf,在[mysqld]下面添加一下代码

代码语言:javascript
复制
#绕过mysql登录所需要输入的密码,直接使用`mysql -uroot -p`登录,输入密码时直接回车
skip-grant-tables
#mysql启动端口,可以默认设置为3306也可以设置为其他的端口
port = 3036
sql-mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
#设置mysql编码为utf8
character_set_server=utf8
init_connect='SET NAMES utf8'
代码语言:javascript
复制
vim /etc/my.cnf
代码语言:javascript
复制
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld]
skip-grant-tables
port = 3036
sql-mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
character_set_server=utf8
init_connect='SET NAMES utf8'
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

重启mysql

代码语言:javascript
复制
systemctl restart mysqld

登录mysql

代码语言:javascript
复制
[root@VM-4-5-centos local]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)

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

输入flush privileges;并设置密码

代码语言:javascript
复制
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> set password for root@localhost=password('new_password');
Query OK, 0 rows affected (0.00 sec)

mysql> exit

重启mysql

代码语言:javascript
复制
systemctl restart mysqld

登录mysql,在Enter password: 后面输入你设置的新密码

代码语言:javascript
复制
[root@VM-4-5-centos local]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.51 MySQL Community Server (GPL)

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

设置可以进行远程连接

代码语言:javascript
复制
mysql> grant all privileges on *.* to root@'%' identified by 'root' with grant option;

重启mysql,并查看编码

代码语言:javascript
复制
[root@VM-4-5-centos local]# systemctl restart mysqld
[root@VM-4-5-centos local]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> SHOW VARIABLES LIKE 'character%';

开放mysql端口

1.如果是远程服务器,则直接在对应的服务器上的防火墙开启端口

2.如果是本地虚拟机,则需要关闭防火墙

查看防火墙状态

代码语言:javascript
复制
systemctl status firewalld.service

停止防火墙

代码语言:javascript
复制
systemctl stop firewalld.service

永久关闭防火墙

代码语言:javascript
复制
systemctl disable firewalld.service

关闭SELinux安全机制

代码语言:javascript
复制
vim /etc/selinux/config
找到并修改: SELINUX=disabled
需要重启系统:reboot

安装nginx

一、在官网现在你想要的版本的nginx的包,小编使用的是nginx-1.21.6.tar.gz版本的包

二、开始安装nginx

切换到/usr/local/目录,并将你下载的jar包上传至当前目录,并解压压缩包

代码语言:javascript
复制
[root@VM-4-5-centos /]# cd /usr/local/
[root@VM-4-5-centos local]# ls -l
总用量 1116
drwxr-xr-x.  2 root root    4096 8月   5 2020 bin
drwxr-xr-x.  2 root root    4096 4月  11 2018 etc
drwxr-xr-x.  2 root root    4096 4月  11 2018 games
drwxr-xr-x.  2 root root    4096 4月  11 2018 include
drwxr-xr-x.  2 root root    4096 4月  11 2018 lib
drwxr-xr-x.  2 root root    4096 4月  11 2018 lib64
drwxr-xr-x.  2 root root    4096 4月  11 2018 libexec
-rw-r--r--   1 root root    6140 11月 12 2015 mysql-community-release-el7-5.noarch.rpm
drwxr-xr-x  11 root root    4096 7月   3 02:28 nginx
drwxr-xr-x   9 1001 1001    4096 7月   3 02:27 nginx-1.21.6
-rw-r--r--   1 root root 1073364 7月   3 02:22 nginx-1.21.6.tar.gz
drwxr-xr-x  14 root root    4096 7月   3 02:18 qcloud
drwxr-xr-x   3 root root    4096 4月  24 14:16 sa
drwxr-xr-x.  2 root root    4096 4月  11 2018 sbin
drwxr-xr-x.  5 root root    4096 3月   7 2019 share
drwxr-xr-x.  2 root root    4096 4月  11 2018 src
[root@VM-4-5-centos local]# tar zxvf nginx-1.21.6.tar.gz

前提准备,安装依赖包

代码语言:javascript
复制
yum install -y zlibyum install gcc-c++
yum install -y openssl openssl-devel zlib-devel
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel

或者是

代码语言:javascript
复制
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

如果在安装依赖包时如果出现error: rpmdb错误,则需要重新构建rpm数据库

代码语言:javascript
复制
cd /var/lib/rpm
rm -rf __db*
rpm --rebuilddb

切换到nginx-1.21.6目录,并实现编译

代码语言:javascript
复制
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
代码语言:javascript
复制
 make
 make install

查看nginx版本

代码语言:javascript
复制
/usr/local/nginx/sbin/nginx -V

切换到/usr/local/nginx/sbin目录

启动nginx

代码语言:javascript
复制
./nginx

刷新nginx

代码语言:javascript
复制
./nginx -s reload

停止nginx

代码语言:javascript
复制
./nginx stop

备份nginx.conf

代码语言:javascript
复制
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.back

查看nginx启动端口

代码语言:javascript
复制
ps -ef|grep nginx
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-07-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 程序猿香蕉 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装mysql
  • 安装nginx
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档