CentOS 7脚本一键安装MySQL5.7、Nginx

安装MySQL

创建 install_mysql.sh

vim install_mysql.sh

内容如下

rpm -e --nodeps mariadb-libs
sudo yum install -y yum-utils
wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
rpm -ivh mysql80-community-release-el7-5.noarch.rpm
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-server
chmod 777 install_mysql.sh
./install_mysql.sh
systemctl start mysqld.service
#启动服务
systemctl status mysqld.service 
#查看mysql服务运行状态

修改密码

查看临时密码

 grep 'temporary password' /var/log/mysqld.log

请添加图片描述
使用上述临时密码登录

mysql -u root -p

默认不能修改简单密码,如果需要可以

set global validate_password_policy=0;
set global validate_password_length=1;
set global validate_password_mixed_case_count=2;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

如果需要使用navicat远程连接mysql需要授权

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' identified by '123456' WITH GRANT OPTION;
flush privileges;

安装Nginx

创建 install_nginx.sh

vim install_nginx.sh

内容如下

yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
tar -zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
./configure
make
make install
ln -s  /usr/local/nginx/sbin/nginx /usr/bin/nginx
chmod 777 install_nginx.sh
source install_nginx.sh

启动、停止Nginx

nginx 
nginx -s stop
nginx -s quit
nginx -s reload

nginx的根目录在/usr/local/nginx/

你可能感兴趣的:(Liunx,nginx,centos,linux)