[TOC]mysql
一、安裝編譯工具:gcc、gcc-c++、make、pcre、pcre-devel、zlib-devel,並關閉防火牆。nginx
[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# setenforce 0 [root@localhost ~]# yum install gcc gcc-c++ pcre pcre-devel make zlib-devel -y
mkdir /abc mount.cifs //192.168.56.1/lamp7 /abc cd /opt/LNMP tar zxvf nginx-1.12.2.tar.gz -C /opt/
)\1577426501771.png)
三、建立運行用戶、組Nginx服務程序默認以 nobody 身份運行,建議爲其建立專門的用戶帳號,以便更準確地控制其訪問權限,增長靈活性、下降安全風險。c++
//建立一個名爲nginx的用戶,不創建宿主文件夾,也禁止登陸到Shell 環境。 useradd -M -s /sbin/nilogin nginx
cd /opt/nginx-1.12.2/ ./configure \ --prefix=/usr/local/nginx \ --user=nginx \ --group=nginx \ --with-http_stub_status_module
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ls -l /usr/local/sbin/nginx
cd /lib/systemd/system vim nginx.service ------------要刷配置參數--------- [Unit] Description=nginx After=network.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/bin/kill -s HUP $MAINPID ExecStop=/usr/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
chmod 754 nginx.service
systemctl start nginx.service netstat -anpt | grep 80
yum install ncurses ncurses-devel bison cmake -y ------------------------------------------------ ncurses //字符終端的包,方便終端操做' bison //函數庫' cmake //沒有configure,使用cmake'
cd /abc/LNMP tar zxvf mysql-boost-5.7.20.tar.gz -C /opt/
useradd -s /sbin/nologin mysql
cd /opt/mysql-5.7.20/ cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ -DSYSCONFDIR=/etc \ -DSYSTEMD_PID_DIR=/usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH-BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH-PERFSCHEMA_STORAGE_ENGINE=1 \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DWITH_BOOST=boost \ -DWITH_SYSTEMD=1
make && make install
chown -R mysql:mysql /usr/local/mysql/
vim /etc/my.cnf //文件裏的原有文件所有刪除,在添加如下內容: [client] port = 3306 default-character-set=utf8 socket = /usr/local/mysql/mysql.sock [mysql] port = 3306 default-character-set=utf8 socket = /usr/local/mysql/mysql.sock [mysqld] user = mysql basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 character_set_server=utf8 pid-file = /usr/local/mysql/mysql.pid socket = /usr/local/mysql/mysql.sock server-id = 1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES ----------------------------------------------------------------------- chown -R mysql.mysql /etc/my.cnf
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile echo 'export PATH' >> /etc/profile source /etc/profile -------------------------------------------------- source /etc/profile//讓變量生效 在 vim /etc/profile 裏可有看到追加的變量
cd /usr/local/mysql/ //bin目錄下有個mysqld bin/mysqld \ --initialize-insecure \ --user=mysql \ --basedir=/usr/local/mysql \ --datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
//設置開機自啓 systemctl enable mysqld //開啓mysql服務 systemctl start mysqld.service //查看端口 netstat -anpt | grep 3306
#設置Mysql密碼 #剛開始沒密碼是空的,直接回車,而後輸入密碼abc123,再次確認abc123,這時就有密碼了 mysqladmin -u root -p password
#登陸數據庫,提示輸入密碼 就輸入剛纔設置的密碼「abc123」 mysql -u root -p