仅为记录一些常用的centOS操作,不定时更新
nginx安装
- CentOS8已在yum官方源中新增了nginx,直接安装
# yum install -y nginx
- 启动nginx
# systemctl start nginx.service
- 设置 nginx 开机自启动
# systemctl enable nginx.service
nginx 配置信息
网站文件存放默认位置(Welcome to nginx 页面)
/usr/share/nginx/html
网站默认站点配置
/etc/nginx/conf.d/default.conf
自定义 nginx 站点配置文件存放目录
/etc/nginx/conf.d/
nginx 全局配置文件
/etc/nginx/nginx.conf
nginx的服务 启动/停止/刷新配置文件/查看状态
# systemctl start nginx.service ##启动nginx服务
# systemctl stop nginx.service ##停止服务
# systemctl restart nginx.service ##重新启动服务
# systemctl list-units --type=service ##查看所有已启动的服务
# systemctl status nginx.service ##查看服务当前状态
# systemctl enable nginx.service ##设置开机自启动
# systemctl disable nginx.service ##停止开机自启动
Mysql安装
- 下载mysql安装包
# mysql 8.0数据库
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# mysql 5.x数据库
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
- 安装mysql
# yum install -y mysql-server
或
# yum install mysql-community-server
- 设置开机启动mysql
systemctl enable mysqld.service
- 检查是否已经安装了开机自动启动
systemctl list-unit-files | grep mysqld
- 开启mysql服务
systemctl start mysqld.service
- 登陆MySql,输入用户名和密码
##为空就不需要输入,默认为空,直接按回车
mysql -uroot -p
- 修改当前用户密码
use mysql;
##密码为设置的数据库密码,牢记
alter user root@localhost identified by '密码';
- 开启远程登录,授权root远程登录
update user set host='%' where user='root';
#命令立即执行生效(刷新!刷新!刷新!踩坑)
#这句表示从mysql数据库的grant表中重新加载权限数据
flush privileges;
- 查看是否成功:
use mysql;
#查看用户表权限: select host,user from user;
```
显示该图 成功
- 最后检查阿里云(阿里云服务器,其他一样)的安全组是否开放3306端口,没有就添加一下:
然后就可以用Navicat远程连接数据库进行操作了
打开Navicat,新建mysql连接,使用SSH隧道
主机: 你的服务器公网ip 端口:默认 用户名:远程连接服务器需要的用户名,默认root 密码:远程连接服务器需要的密码
切到常规选项
连接名:起个名字,比如 阿里云 主机:默认 端口:默认 用户名:数据库的管理员用户名,默认root 密码:刚才牢记的数据库密码
点击测试连接,连接成功,完成