美文网首页
EL-ADMIN 后台管理系统搭建环境并启动运行(Mac)

EL-ADMIN 后台管理系统搭建环境并启动运行(Mac)

作者: IT姑凉 | 来源:发表于2020-01-03 22:03 被阅读0次

    EL-ADMIN 后台管理系统
    一个基于 Spring Boot 2.1.0 、 Spring Boot Jpa、 JWT、Spring Security、Redis、Vue的前后端分离的后台管理系统。
    https://github.com/elunez/eladmin-web

    一、所需环境

    1、JDK:1.8+
    $ java -version
    // java version "1.8.0_231"
    // Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
    // Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
    
    2、Redis 3.0+

    homebrew 安装 redis

    $ brew search redis 
    $ brew install redis@3.2
    //提示
    ==> Downloading http://download.redis.io/releases/redis-3.2.12.tar.gz
    ######################################################################## 100.0%
    ==> make install PREFIX=/usr/local/Cellar/redis@3.2/3.2.12 CC=clang
    ==> Caveats
    redis@3.2 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    If you need to have redis@3.2 first in your PATH run:
      echo 'export PATH="/usr/local/opt/redis@3.2/bin:$PATH"' >> ~/.bash_profile
    
    
    To have launchd start redis@3.2 now and restart at login:
      brew services start redis@3.2
    Or, if you don't want/need a background service you can just run:
      /usr/local/opt/redis@3.2/bin/redis-server /usr/local/etc/redis.conf
    ==> Summary
    🍺  /usr/local/Cellar/redis@3.2/3.2.12: 11 files, 1.7MB, built in 3 minutes 44 seconds
    

    相关命令:

    $ brew services start redis@3.2  //启动redis服务
    $ brew services stop redis@3.2 //关闭redis服务
    $ brew services restart redis@3.2 //重启redis服务
    $ brew services list //查看brew安装的服务状态
    
    3、Maven 3.0+
    $ mvn -v
    // Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
    // Maven home: /Users/itguliang/Documents/maven/apache-maven-3.6.0
    // Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/jre
    // Default locale: zh_CN, platform encoding: UTF-8
    // OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"
    
    4、MYSQL 5.5.0+
    #安装
    $ brew search mysql 
    $ brew install mysql@5.7  //选择版本
    $ which mysql #查看sql安装位置
    /usr/local/opt/mysql@5.7/bin/mysql
    
    #卸载
    $ brew uninstall mysql@5.7
    $ brew cleanup
    $ launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
    $ rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
    $ sudo rm -rf /usr/local/var/mysql
    

    安装提示:

    ==> Downloading https://homebrew.bintray.com/bottles/mysql@5.7-5.7.28.high_sierra.bottle.tar.gz
    ==> Downloading from https://akamai.bintray.com/c4/c4b91823da381ca3f5c1d4016b35b0f5c02c947eecad788541cb666bfbb49290?__gda__=exp=1
    ######################################################################## 100.0%
    ==> Pouring mysql@5.7-5.7.28.high_sierra.bottle.tar.gz
    ==> Caveats
    We've installed your MySQL database without a root password. To secure it run:
        mysql_secure_installation
    
    MySQL is configured to only allow connections from localhost by default
    
    To connect run:
        mysql -uroot
    
    mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    If you need to have mysql@5.7 first in your PATH run:
      echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
    
    For compilers to find mysql@5.7 you may need to set:
      export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
      export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
    
    For pkg-config to find mysql@5.7 you may need to set:
      export PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig"
    
    To have launchd start mysql@5.7 now and restart at login:
      brew services start mysql@5.7
    Or, if you don't want/need a background service you can just run:
      /usr/local/opt/mysql@5.7/bin/mysql.server start
    ==> Summary
    🍺  /usr/local/Cellar/mysql@5.7/5.7.28: 319 files, 235.3MB
    

    mysql_secure_installation 设置密码以及删除一些账户

    $ mysql_secure_installation
    
    Securing the MySQL server deployment.
    Connecting to MySQL using a blank password.
    VALIDATE PASSWORD COMPONENT can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD component?
    Press y|Y for Yes, any other key for No: y
    
    There are three levels of password validation policy:
    LOW    Length >= 8  
    MEDIUM Length >= 8, numeric, mixed case, and special characters  
    STRONG Length >= 8, numeric, mixed case, special characters and dictionary file  
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
    
    Please set the password for root here.
    New password:
    Re-enter new password:
    Estimated strength of the password: 100
    
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    
    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? (Press y|Y for Yes, any other key for No) : y   //删除匿名用户 
    
    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? (Press y|Y for Yes, any other key for No) : y  //禁止root远程登录
    
     ... skipping.
    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? (Press y|Y for Yes, any other key for No) : y //删除test数据库
     - Dropping test database...
    Success.
     - 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? (Press y|Y for Yes, any other key for No) : y   //刷新权限表,以确保所有的修改可以立刻生效
    Success.   
    
    All done!
    

    登录

    $ mysql -uroot -p //用刚刚设置的密码登录
    
    5、Node v10+
    $ node -v  // v10.11.0
    

    二、后端启动

    1、克隆项目:

    $ git clone https://gitee.com/elunez/eladmin.git
    

    2、导入数据:打开数据库,创建一个新库 eladmin,导入sql文件夹中的初始化脚本

    $ mysql -uroot -p  //登录数据库
    mysql > SHOW DATABASES;
    mysql > CREATE DATABASE eladmin;
    mysql > use eladmin;
    mysql > source  项目路径/eladmin/sql/eladmin.sql  //执行sql语句
    

    3、IDEA 打开项目, 待自动安装 maven 依赖,修改数据库密码,启动项目:

    修改数据库密码 启动项目

    三、前端启动

    1、克隆项目:

    $ git clone https://gitee.com/elunez/eladmin-web.git
    

    2、安装依赖:打开项目后输入命令安装依赖

    $ npm install
    

    3、 运行项目:

    $ npm run dev
    

    遇到问题记录:

    1、Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    连接localhost通常通过一个Unix域套接字文件进行,一般是/tmp/mysql.sock。如果套接字文件被删除了,本地客户就不能连接。这可能发生在你的系统运行一个cron任务删除了/tmp下的临时文件。

    sudo rm -rf /usr/local/var/mysql/
    brew install mysql@5.7
    brew postinstall mysql@5.7
    

    通过卸载重新安装,解决了可以登录了,但是不是长久之计,/tmp/mysql.sock还是会不小心被删除

    自己建立一个mysql.sock文件,放到mysql目录下,然后使用软链接指向到tmp文件夹下

    $ ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock
    

    /usr/local/etc/my.cnf

    [mysqld]
    port = 3306
    socket = /usr/local/var/mysql/mysql.sock
    

    改了这里,重启又报错,改回去,重启又好了

    2、unknown variable 'mysqlx-bind-address=127.0.0.1'

    If you are able to find your my.cnf file (for me, it was in /usr/local/etc/my.cnf) you should remove the below line:

    mysqlx-bind-address = 127.0.0.1
    

    相关文章

      网友评论

          本文标题:EL-ADMIN 后台管理系统搭建环境并启动运行(Mac)

          本文链接:https://www.haomeiwen.com/subject/oynjoctx.html