如何搭建自己的网站(二)

一、ubuntu安装数据库

1.安装

安装:sudo apt-get install mysql-server
查看版本:mysql -V
查看运行状态:sudo netstat -tap | grep mysql

2.寻找初始密码

cd /etc/mysql
sudo vim debian.cnf

 

3.登录

mysql -u debian-sys-maint -p
Enter password: xxxxxxxxxxxxxxxx

4.修改密码

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxx';

5.修改远程连接

use mysql;
select host,user from user;
update user set host = '%' where user = 'root';
flush privileges;

二、mybatis连接数据库

1.新建demoMybatis项目

勾选mybatis、jdbc等依赖。

2.修改application.properties配置文件

可以将这个文件拆成三个,一个是选择启动文件的application.yml,一个是开发环境application-dev.yml,一个是生产环境application-prod.yml,生产环境的url将localhost替换成远程数据库地址,详细如下:

spring:
  profiles:
    active: prod
server:
  port: 8080
spring:
  datasource:
    username: root
    password: 123456
    url: jdbc:mysql://82.157.160.30:3306/ache?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
    driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
  mapper-locations: classpath:mapping/*Mapper.xml
  type-aliases-package: com.example.demoMybatis.entity
#showSql
logging:
  level:
    com:
      example:
        mapper: debug

3.写查询的接口

mapper



数据库:



测试一下:



常规打包mvn clean package、常规上传、查找容器docker ps、查找镜像docker images、kill容器docker kill CONTAINERID、移除容器docker rm CONTAINERID、移除镜像docker rmi IMAGEID构建镜像docker build -t my/demo .运行容器docker run -d --name demo -p 8080:8080 my/demo 

三、vue搜索关键字高亮

const highLight = (allText, keyword) => {
  let Reg = new RegExp(keyword, "ig");
  if (allText) {
    let execRes = Reg.exec(allText.toString()); //得到一个匹配结果的集合,包含关键字出现的索引
    if (execRes) {
      let realword = allText.substr(execRes.index, keyword.length); //根据索引和关键字长度获取原本的真实大小写关键词
      let res = allText.replace(
        Reg,
        `<span style="color: red;">${realword}</span>`
      );
      return res;
    } else return allText;
  } else return allText;
};
<h3 v-html="highLight(item.title, filter.search)"></h3>
<p v-html="highLight(item.detail, filter.search)"></p>

四、成功辽

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值