一凡资、Mysql安裝
1采盒、檢測(cè)系統(tǒng)是否自帶Mysql
>rmp -qa|grep mysql
如果有進(jìn)行強(qiáng)行卸載
>rpm -e --nodeps mysql-libs-5.1.52-1.el6_0.1.x86_64
2品洛、檢測(cè)系統(tǒng)是否自帶mariadb
>rpm -qa|grep mariadb
>rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
3病附、解壓安裝包
>tar -zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
4殿漠、重命名
>mv mysql-5.7.32-linux-glibc2.12-x86_64 mysql-5.7
>mv mysql-5.7 /usr/local/
5、檢查mysql組和用戶是否存在卤妒,如果沒有則創(chuàng)建
>cat /etc/group|grep mysql
>groupadd mysql
>useradd -r -g mysql -s /bin/false mysql
6甥绿、安裝數(shù)據(jù)庫(kù)
>cd /usr/local/mysql-5.7
>mkdir data
7、將/usr/local/mysql-5.7的所有者及所屬組改為mysql
>chown -R mysql.mysql /usr/local/mysql-5.7
8则披、在/usr/local/mysql-5.7/support-files目錄下創(chuàng)建my_default.cnf
>cd support-files/
>vim my_default.cnf
[mysqld]
#設(shè)置mysql的安裝目錄
basedir =/usr/local/mysql-5.7
#設(shè)置mysql數(shù)據(jù)庫(kù)的數(shù)據(jù)存放目錄
datadir = /usr/local/mysql-5.7/data
#設(shè)置端口
port = 3306
socket = /tmp/mysql.sock
#設(shè)置字符集
character-set-server=utf8
#日志存放目錄
log-error = /usr/local/mysql-5.7/data/mysqld.log
pid-file = /usr/local/mysql-5.7/data/mysqld.pid
#允許時(shí)間類型的數(shù)據(jù)為零(去掉NO_ZERO_IN_DATE,NO_ZERO_DATE)
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
9共缕、拷貝配置文件到/etc/
>cp my_default.cnf /etc/my.cnf
10、初始化Mysql
>cd ../bin/
>./mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7/ --datadir=/usr/local/mysql-5.7/data/
如果報(bào)錯(cuò):./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or 就安裝libaio士复,如果沒有則跳過(guò)
>yum install libaio
>./mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7/ --datadir=/usr/local/mysql-5.7/data/
11图谷、查看臨時(shí)密碼
>cat /usr/local/mysql-5.7/data/mysqld.log
12翩活、把啟動(dòng)腳本放到開機(jī)初始化目錄
>cp support-files/mysql.server /etc/init.d/mysql
12、啟動(dòng)mysql
service mysql start
二便贵、修改密碼
1菠镇、進(jìn)入mysql
>cd /usr/local/mysql-5.7/bin/
>.mysql -u root -p
2、設(shè)置密碼
>set password=password('123456');
>grant all privileges on *.* to root@'%' identified by '123456';
>flush privileges;
3承璃、設(shè)置遠(yuǎn)程訪問(wèn)
>use mysql;
>update user set host='%' where user = 'root';
> flush privileges;
三利耍、nginx安裝
1、下載解壓
>tar -zxvf nginx-1.19.5.tar.gz
>mv nginx-1.19.5 nginx1.19
>mv nginx1.19 /usr/local/
>yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
>cd /usr/local/nginx1.19/
>./configure --prefix=/usr/local/nginx
>make
>make install