Linux yum 安裝Java和MySQL

一、Linux配置Java環境java

CentOS系統默認是帶有yum(軟件包依賴管理工具)的,Ubuntu是apt,macOS是homebrewnode

yum -y update 升級全部包同時也升級軟件和系統內核mysql

yum -y upgrade 只升級全部包,不升級軟件和系統內核sql

 

安裝以前先檢查一下系統有沒有自帶open-jdk數據庫

rpm -qa |grep java安全

rpm -qa |grep jdk服務器

rpm -qa |grep gcjsocket

若是沒有輸入信息表示沒有安裝。工具

若是安裝能夠使用 rpm -qa | grep java | xargs rpm -e --nodeps 批量卸載全部帶有Java的文件  這句命令的關鍵字是javaspa

yum list java*  檢索包含java的列表

yum install java-1.8.0-openjdk* -y  安裝1.8.0的全部文件


java -version  檢查是否安裝成功(yum安裝都不用配置環境變量)

 

二、Linux配置MySQL

yum安裝MySQL,主要是3個包

mysql-devel 開發用到的庫以及包含文件
mysql mysql 客戶端
mysql-server 數據庫服務器

 

安裝以前,先說收如何完全卸載MySQL

用命令rpm -qa|grep -i mysql查看已經安裝的MySQL安裝包,在列表中逐個卸載

yum remove mysql mysql-server mysql-libs compat-mysql51 

rm -rf /var/lib/mysql  

rm /etc/my.cnf

 

查看之前是否安裝過

yum list installed mysql*

rpm -qa | grep mysql*

 

安裝MySQL

yum install mysql

yum install mysql-server

yum install mysql-devel

 

配置MySQL

[root@wood /]# cat /etc/my.cnf

[client]

default-character-set=utf8

 

[mysql]

default-character-set = utf8

 

[mysqld]

character_set_server=utf8

character_set_client=utf8

collation-server=utf8_general_ci

max_connections=100

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

 

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

 

 

開機啓動 MySQL

chkconfig -add mysqld

 

 

啓動、中止 MySQL

service mysqld start

service mysqld stop

service mysqld restart

 

第一次啓動會彈出

[root@wood ~]# service mysqld start

Initializing MySQL database:  Installing MySQL system tables...

OK

Filling help tables...

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/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h wood password 'new-password'

 

Alternatively you can run:

/usr/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 ; /usr/bin/mysqld_safe &

 

You can test the MySQL daemon with mysql-test-run.pl

cd /usr/mysql-test ; perl mysql-test-run.pl

 

Please report any problems with the /usr/bin/mysqlbug script!

 

設置管理員密碼

設置mysql管理員密碼

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h localhost password 'new-password'

配置mysql安裝嚮導

/usr/bin/mysql_secure_installation

 

修改localhost,任何IP均可以遠程訪問mysql服務器
更改 "mysql" 數據庫裏的 "user" 表裏的 "host" 項,從"localhost"改爲"%" 
mysql>use mysql; 
mysql>update user set host = '%' where user = 'root'; 
mysql>select host, user from user;
mysql>FLUSH PRIVILEGES;

 

爲了安全,我是這樣設置的

話說IP怎麼查?

相關文章
相關標籤/搜索