• yum安装mariadb数据库


    一、一台主机安装mysql数据库

    1、安装软件包

    [root@localhost ~]# yum -y install mariadb-server mariadb

    2、开启服务

    [root@localhost ~]# systemctl start mariadb

    3、查看是否有3306端口

    [root@localhost ~]# netstat -anpt 
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 0.0.0.0:3306            0.0.0.0:*      

    4、登录数据库

    [root@localhost ~]# mysql
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 2
    Server version: 5.5.41-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MariaDB [(none)]> 

    建一个数据库

    MariaDB [(none)]> create database slsaledb;
    Query OK, 1 row affected (0.00 sec)

    给数据库授权

    MariaDB [(none)]> grant all on slsaledb.* to admin@'%' identified by '123123';
    Query OK, 0 rows affected (0.00 sec)

    %:连接可以来源于任何地址

    刷新一下授权表

    MariaDB [(none)]> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    退出

    MariaDB [(none)]> exit
    Bye
    [root@localhost ~]# 

    5、向数据库中导入数据

    添加一个*.sql的文件

    [root@localhost ~]# rz -E
    rz waiting to receive.
    [root@localhost ~]# ls
    anaconda-ks.cfg  nginx-1.16.0.tar.gz  slsaledb-2014-4-10.sql

    将文件导入数据库

    [root@localhost ~]# mysql -uroot < slsaledb-2014-4-10.sql

    二、将安装tomcat的主机连接到数据库

    1、修改网页文件下的内容

    [root@localhost ~]# ls /web/webapp/
    index.jsp  SLSaleSystem
    [root@localhost ~]# ls /web/webapp/SLSaleSystem/
    logs  META-INF  statics  WEB-INF
    [root@localhost ~]# ls /web/webapp/SLSaleSystem/WEB-INF/
    classes  lib  pages  web.xml
    [root@localhost ~]# ls /web/webapp/SLSaleSystem/WEB-INF/classes/
    applicationContext-mybatis.xml  mybatis-config.xml
    jdbc.properties                 org
    log4j.properties                spring-servlet.xml
    [root@localhost ~]# vim /web/webapp/SLSaleSystem/WEB-INF/classes/jdbc.properties
    [root@localhost ~]# vim /web/webapp/SLSaleSystem/WEB-INF/classes/jdbc.properties
    url=jdbc:mysql://192.168.200.111:3306/slsaledb?useUnicode=true&characterEncoding=UTF-8    //数据库主机的IP
    
    uname=admin   //数据库的用户名
    password=123123    //数据库的密码

     测试(用户名admin,密码123456登录)

    如果在测试过程中,nginx主机登录的时候总是跳转,登陆不进去,就需要在主配置文件中添加如下:

    upstream tomcat_server {
                    ip_hash;   //将网页固定到当前页执行
                    server 192.168.200.112:8080 weight=1;
                    server 192.168.200.113:8080 weight=1;
    }
    
    server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html;
                index  index.html index.htm;
            proxy_set_header Host $http_host;
            proxy_pass http://tomcat_server;
            }
  • 相关阅读:
    Java编程语言学习01-Java语言概述
    Java复习面试指南-06为什么要进行数据类型转换?什么情况下会进行自动类型转换?
    Java复习面试指南-05简单说一下Java当中的char字符类型?
    Java复习面试指南-04Java语言支持的8种基本数据类型是什么?占用的空间是多少?
    Java复习面试指南03-说一下Java当中标识符与关键字的区别?
    Linq LeftJoin 取不同和想同的对像
    vue父组件异步传递prop到子组件echarts画图问题踩坑总结
    linux下使用openssl生成https的crt和key证书
    css hover延时 解决快速划入划出
    记录时间操作
  • 原文地址:https://www.cnblogs.com/tanxiaojuncom/p/11573403.html
Copyright © 2020-2023  润新知