linux 系統 環境部署
1.jdk 安裝
1).tar -zxvf jdk-1.7.0….,修改解壓後的包名為 jdk7
2).配置環境變數
開啟/etc/profile,在檔案最後新增
export JAVA_HOME=/usr/local/jdk7
export JRE_HOME=/usr/local/jdk7/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
使環境變數立即生效,輸入命令:source /etc/profile
2.tomcat 安裝
1).tar -zxvf apache-tomcat-7.0.69….
2).修改server.xml
3.mysql資料庫安裝
檢視系統版本
[mysql@localhost scripts]$ uname -a
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
- 解壓:[[email protected] mysql]# tar -zxf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz 修改名字為mysql
- 建立mysql使用者:[[email protected] mysql]# useradd mysql
- 設定mysql使用者密碼:[[email protected] mysql]# echo ‘123456’|passwd –stdin mysql
- 設定許可權:
[[email protected] mysql]# cd /usr/local
[[email protected] local]# chown -R mysql:mysql mysql/ - 切換到mysql使用者
- [[email protected] local]# su - mysql
[ - 安裝:
[[email protected] scripts]$ ./mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data
輸出資訊:
[[email protected] scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Installing MySQL system tables...2016-04-17 07:41:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-17 07:41:40 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3394 ...
2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2016-04-17 07:41:40 3394 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-04-17 07:41:40 3394 [Note] InnoDB: The InnoDB memory heap is disabled
2016-04-17 07:41:40 3394 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-04-17 07:41:40 3394 [Note] InnoDB: Memory barrier is not used
2016-04-17 07:41:40 3394 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-04-17 07:41:40 3394 [Note] InnoDB: Using Linux native AIO
2016-04-17 07:41:40 3394 [Note] InnoDB: Using CPU crc32 instructions
2016-04-17 07:41:40 3394 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-04-17 07:41:40 3394 [Note] InnoDB: Completed initialization of buffer pool
2016-04-17 07:41:41 3394 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-04-17 07:41:41 3394 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-04-17 07:41:41 3394 [Note] InnoDB: Database physically writes the file full: wait...
2016-04-17 07:41:41 3394 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-04-17 07:41:42 3394 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-04-17 07:41:44 3394 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-04-17 07:41:44 3394 [Warning] InnoDB: New log files created, LSN=45781
2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer created
2016-04-17 07:41:44 3394 [Note] InnoDB: 128 rollback segment(s) are active.
2016-04-17 07:41:44 3394 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-04-17 07:41:44 3394 [Note] InnoDB: Foreign key constraint system tables created
2016-04-17 07:41:44 3394 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-04-17 07:41:44 3394 [Note] InnoDB: Tablespace and datafile system tables created.
2016-04-17 07:41:44 3394 [Note] InnoDB: Waiting for purge to start
2016-04-17 07:41:44 3394 [Note] InnoDB: 5.6.30 started; log sequence number 0
2016-04-17 07:41:45 3394 [Note] Binlog end
2016-04-17 07:41:45 3394 [Note] InnoDB: FTS optimize thread exiting.
2016-04-17 07:41:45 3394 [Note] InnoDB: Starting shutdown...
2016-04-17 07:41:46 3394 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2016-04-17 07:41:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-17 07:41:46 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3417 ...
2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2016-04-17 07:41:46 3417 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-04-17 07:41:46 3417 [Note] InnoDB: The InnoDB memory heap is disabled
2016-04-17 07:41:46 3417 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-04-17 07:41:46 3417 [Note] InnoDB: Memory barrier is not used
2016-04-17 07:41:46 3417 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-04-17 07:41:46 3417 [Note] InnoDB: Using Linux native AIO
2016-04-17 07:41:46 3417 [Note] InnoDB: Using CPU crc32 instructions
2016-04-17 07:41:46 3417 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-04-17 07:41:46 3417 [Note] InnoDB: Completed initialization of buffer pool
2016-04-17 07:41:46 3417 [Note] InnoDB: Highest supported file format is Barracuda.
2016-04-17 07:41:46 3417 [Note] InnoDB: 128 rollback segment(s) are active.
2016-04-17 07:41:46 3417 [Note] InnoDB: Waiting for purge to start
2016-04-17 07:41:46 3417 [Note] InnoDB: 5.6.30 started; log sequence number 1625977
2016-04-17 07:41:46 3417 [Note] Binlog end
2016-04-17 07:41:46 3417 [Note] InnoDB: FTS optimize thread exiting.
2016-04-17 07:41:46 3417 [Note] InnoDB: Starting shutdown...
2016-04-17 07:41:48 3417 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
這裡可能會報錯:scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory。
需要安裝perl以及perl-devel.執行命令:yum –y install perl perl-devel
重點注意:這裡要從mysql使用者切換成root使用者
[[email protected] support-files]$ su - root
Password: 輸入密碼 ,然後切換到cd usr/local/mysql/support-files/
配置檔案
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysql # 注意這裡的mysql是服務,不是檔案
vim /etc/init.d/mysql #若mysql的安裝目錄是/usr/local/mysql,則可省略此步
修改檔案中的兩個變更值
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
配置環境變數
vi /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
儲存退出
source /etc/profile
啟動
[[email protected] mysql]# chkconfig --add mysql
[[email protected] mysql]# chkconfig mysql on
[[email protected] mysql]# service mysql start
Starting MySQL.. SUCCESS!
設定root登入密碼:第一次預設是空
1.如果沒改過密碼的
# mysql -uroot -p
Enter password: 【輸入原來的密碼,第一次為空】
mysql>use mysql;
mysql> update user set password=passworD("test") where user='root';
mysql> flush privileges;
mysql> exit;
2.改過密碼忘記了的
首先,你必須要有作業系統的root許可權了。要是連繫統的root許可權都沒有的話,先考慮root系統再走下面的步驟。
類似於安全模式登入系統,有人建議說是pkill mysql,但是我不建議哈。因為當你執行了這個命令後,會導致這樣的狀況:
/etc/init.d/mysqld status
mysqld dead but subsys locked
這樣即使你是在安全模式下啟動mysql都未必會有用的,所以一般是這樣/etc/init.d/mysqld stop,如果你不幸先用了pkill,那麼就start一下再stop咯。
# mysqld_safe --skip-grant-tables &
&,表示在後臺執行,不再後臺執行的話,就再開啟一個終端咯。
# mysql
mysql> use mysql;
mysql> UPDATE user SET password=password("test123") WHERE user='root';
mysql> flush privileges;
mysql> exit;
設定登入許可權:
mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
如果還不能外部連結,用客戶端telnet 訪問下3306介面是否是通的。
參考文獻 :https://blog.csdn.net/zhangming1013/article/details/51176242