[root@web108 tools]# ###開始裝mysql 1添加用戶 [root@web108 tools]# useradd -s /sbin/nologin -M mysql 2解壓 [root@web108 tools]# tar xf mysql-5.6.34-linux-glibc ...
[root@web108 tools]# ###開始裝mysql
1添加用戶
[root@web108 tools]# useradd -s /sbin/nologin -M mysql
2解壓
[root@web108 tools]# tar xf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
[root@web108 tools]# echo $?
0
3把mysql移動
[root@web108 tools]# mv mysql-5.6.34-linux-glibc2.5-x86_64 /application/mysql-5.6.34
[root@web108 tools]# ll
total 306792
-rw-r--r-- 1 root root 314149697 Sep 13 10:13 mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
-rw-r--r-- 1 root root 607 Sep 11 09:50 quanwangweb.sh
[root@web108 tools]# cd /application/
[root@web108 application]# cd mysql-5.6.34/
[root@web108 mysql-5.6.34]# cd ..
4創建軟連接
[root@web108 application]# ln -s /application/mysql-5.6.34 /application/mysql
[root@web108 application]# ll
total 8
lrwxrwxrwx 1 root root 25 Sep 13 10:30 mysql -> /application/mysql-5.6.34
drwxr-xr-x 13 root root 4096 Sep 13 10:19 mysql-5.6.34
lrwxrwxrwx 1 root root 25 Sep 12 09:02 nginx -> /application/nginx-1.10.2
drwxr-xr-x 11 root root 4096 Sep 12 09:14 nginx-1.10.2
[root@web108 application]# id mysql
uid=502(mysql) gid=502(mysql) groups=502(mysql)
5讓mysql用戶管理
[root@web108 application]# chown -R mysql.mysql /application/mysql/
[root@web108 application]# ll /application/mysql
lrwxrwxrwx 1 mysql root 25 Sep 13 10:30 /application/mysql -> /application/mysql-5.6.34
[root@web108 application]# ll /application/mysql/
total 68
drwxr-xr-x 2 mysql mysql 4096 Sep 13 10:18 bin
-rw-r--r-- 1 mysql mysql 17987 Sep 30 2016 COPYING
drwxr-xr-x 3 mysql mysql 4096 Sep 13 10:19 data
drwxr-xr-x 2 mysql mysql 4096 Sep 13 10:19 docs
drwxr-xr-x 3 mysql mysql 4096 Sep 13 10:19 include
drwxr-xr-x 3 mysql mysql 4096 Sep 13 10:19 lib
drwxr-xr-x 4 mysql mysql 4096 Sep 13 10:18 man
drwxr-xr-x 10 mysql mysql 4096 Sep 13 10:19 mysql-test
-rw-r--r-- 1 mysql mysql 2496 Sep 30 2016 README
drwxr-xr-x 2 mysql mysql 4096 Sep 13 10:19 scripts
drwxr-xr-x 28 mysql mysql 4096 Sep 13 10:18 share
drwxr-xr-x 4 mysql mysql 4096 Sep 13 10:19 sql-bench
drwxr-xr-x 2 mysql mysql 4096 Sep 13 10:19 support-files
6安裝這個軟體 初始化資料庫
[root@web108 application]# /application/mysql/scripts/mysql_install_db --basedir=/al_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
[root@web108 application]# echo $?
0
[root@web108 application]# ll -d /tmp/
drwxrwxrwt. 3 root root 4096 Sep 13 10:40 /tmp/
[root@web108 application]# chmod 1777 /tmp/
7複製啟動腳本授權
[root@web108 application]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@web108 application]# chmod +x /etc/init.d/mysqld
[root@web108 application]# cd /server/tools/
8 修改啟動腳本和mysql命令中的路徑
[root@web108 tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
9 複製 預設的配置文件
[root@web108 tools]# \cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
10 啟動 mysql
[root@web108 tools]# /etc/init.d/mysqld start
Starting MySQL...... SUCCESS!
[root@web108 tools]#