Linux Mysql安装和配置(基于CentOS 6)
本篇描述Linux下Mysql和tomcat(基于jdk)的基础环境配置
Mysql
-
查询已安装的mysql(一般为Linux自带)
rpm –qa | grep mysql
-
强力卸载mysql
rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
-
查看可安装的mysql及相关版本
yum list | grep mysql
-
安装mysql
yum -y install mysql-server mysql mysql-devel
-
启动mysql
service mysqld start
-
配置mysql开机启动
chkconfig --list | grep mysqld
chkconfig mysqld on
-
设置mysql root用户密码(默认密码为空)
mysqladmin -u root password ‘123456‘
mysql -u root -p
-
配置远程访问权限
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
flush privileges
-
mysql配置相关
-
vi /etc/my.cnf mysql主配置文件
-
ll /var/lib/mysql/ mysql数据库文件存放位置
-
vi /var/log/msqld.log
-
配置防火墙:
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
vi /etc/sysconfig/iptables(将-AINPUT -p tcp -m tcp --dport 3306 -j ACCEPT
行放在
-A INPUT -j REJECT --reject-with icmp-host-prohibited
行的前面,否则不能连通)service iptables restart
-
tomcat
jdk
-
上传jdk包至相关文件夹
tar -xzvf jdk-8u172-linux-x64.tar.gz -C /opt
-
vi ~/.bask_profile
配置用户环境变量,添加JAVA_HOME=/opt/jdk1.8.0_172 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin CLASSPATH=$JAVA_HOME/lib
source ~/.bash_profile
java
javac
apache-tomcat
-
上传apache-tomcat至相关文件夹
tar -xzvf apache-tomcat-9.0.8.tar.gz -C /opt/
-
vi ~/.bask_profile`配置用户环境变量,添加
CATALINA_HOME=/opt/apache-tomcat-9.0.8 CATALINA_BASE=$CATALINA_HOME source ~/.bash_profile cd /opt/apache-tomcat-9.0.8/bin
跳转至tomcat/bin文件夹
/startup.sh
http://host:8080
出现如下界面即配置成功,后续war包等均放置在webapp下