如何在腾讯云centos7中安装mysql,Tomcat超全详细

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_39148512/article/details/79764425

温馨提示:在开始安装之前,必须用 开启root用户,server.xml修改配置后才能正常使用80端口

sudo su 切换到root用户


下载

  1. wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
复制代码
安装
  1. rpm -ivh mysql57-community-release-el7-11.noarch.rpm
复制代码
安装完成之后,我们发现在/etc/yum.repos.d目录下新增了两个文件:

其中第二文件记录了mysql的源信息。mysql-community.repo mysql-community-source.repo

yum 安装mysql
  1. yum install mysql-community-server
复制代码
启动mysql服务
  1. systemctl start mysqld
复制代码
查看mysql服务的状态
  1. systemctl status mysqld
复制代码
开机启动
  1. systemctl enable mysqld
  2. systemctl daemon-reload
复制代码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
  1. grep 'temporary password' /var/log/mysqld.log
复制代码
用刚刚查到的密码登录
  1. mysql -uroot -p
复制代码
修改密码
  1. set password for 'root'@'localhost'=password('MyNewPass!');
复制代码

如果出现Your password does not satisfy the current policy requirements 密码:大小写数字特殊字符 全用上吧


开启mysql的远程登录

默认情况下mysql为安全起见,不支持远程登录mysql,所以需要设置开启 远程登录mysql的权限

登录mysql后输入如下命令:

grant all privileges on *.* to 'root' @'%' identified by '填写root的密码' with grant opttion;

flush privileges;

 

开放Linux的对外访问的端口3306

/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

/etc/rc.d/init.d/iptables save ---将修改永久保存到防火墙中



修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示: 

[mysqld] 
character_set_server=utf8 
init_connect='SET NAMES utf8'

重启mysql

systemctl restart mysqld


启动数据库

#service mysqld start

可通过检查端口是否开启来查看MySQL是否正常启动:

[root@xxx]#netstat -anp|grep 3306

tcp        0     0 0.0.0.0:3306               0.0.0.0:*                   LISTEN      34693/mysqld

修改密码等配置:

复制代码
#######启动mysql服务进程
[root@typecodes ~]# systemctl start mysqld

#######配置mysql(设置密码等)
[root@typecodes ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y                  [设置root用户密码]
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y                 [删除匿名用户]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y       [禁止root远程登录]
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y          [删除test数据库]
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y            [刷新权限]
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...

安装Tomcat

1)上传Tomcat到linux上

2)解压Tomcat到/usr/local下

3)开放Linux的对外访问的端口8080

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

/etc/rc.d/init.d/iptables save

4)启动关闭Tomcat

进入tomcat的bin下启动:./startup.sh

进入tomcat的bin下关闭:./shutdown.sh



不管防火墙关没关,都是用systemctl stop firewalld 关闭防火墙。

然后使用yum install iptables-service 安装或者更新服务


猜你喜欢

转载自blog.csdn.net/weixin_39148512/article/details/79764425