Ubuntu 22.04 安装MariaDB 提供本地服务

因为部署安装Seafile需求Ubuntu 22.04,需要提供MySQL数据库服务,因此简单部署MariaDB 提供本地服务

  1. 更新包列表:

    sudo apt update
  2. 安装MariaDB服务器:

    sudo apt install mariadb-server
  3. 安装完成后,运行安全安装脚本来设置密码和调整安全选项:

    sudo mysql_secure_installation

    内部演示如下:

    root@seafile-server:/opt# mysql_secure_installation
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MariaDB to secure it, we'll need the current
    password for the root user. If you've just installed MariaDB, and
    haven't set the root password yet, you should just press enter here.
    
    Enter current password for root (enter for none):
    OK, successfully used password, moving on...
    
    Setting the root password or using the unix_socket ensures that nobody
    can log into the MariaDB root user without the proper authorisation.
    
    You already have your root account protected, so you can safely answer 'n'.
    
    Switch to unix_socket authentication [Y/n] n
     ... skipping.
    
    You already have your root account protected, so you can safely answer 'n'.
    
    Change the root password? [Y/n] Y
    New password:
    Re-enter new password:
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MariaDB installation has an anonymous user, allowing anyone
    to log into MariaDB 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
     ... Success!
    
    By default, MariaDB 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
     - 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? [Y/n] Y
     ... Success!
    
    Cleaning up...
    
    All done!  If you've completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!
    root@seafile-server:/opt# systemctl
  4. 启动MariaDB服务:

    sudo systemctl start mysql
  5. 设置MariaDB服务开机自启:

    sudo systemctl enable mysql
  6. 登录到MariaDB以确保一切正常:

    mysql -u root -p

    输入你在安全安装期间设置的密码

    root@seafile-server:/opt# mysql -u root -p
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 39
    Server version: 10.6.18-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.001 sec)
    
    MariaDB [(none)]> exit
    Bye

    数据库部署完成

     

     

     

    查看代码
     root@seafile-server:/opt/seafile/seafile-server-11.0.9# ./setup-seafile-mysql.sh
    Checking python on this machine ...
    
    -----------------------------------------------------------------
    This script will guide you to setup your seafile server using MySQL.
    Make sure you have read seafile server manual at
    
            https://download.seafile.com/published/seafile-manual/home.md
    
    Press ENTER to continue
    -----------------------------------------------------------------
    
    What is the name of the server? It will be displayed on the client.
    3 - 15 letters or digits
    [ server name ]
    What is the name of the server? It will be displayed on the client.
    3 - 15 letters or digits
    [ server name ] Seafile-Server
    
    What is the ip or domain of the server?
    For example: www.mycompany.com, 192.168.1.101
    [ This server's ip or domain ] 10.10.8.21
    
    Which port do you want to use for the seafile fileserver?
    [ default "8082" ]
    
    -------------------------------------------------------
    Please choose a way to initialize seafile databases:
    -------------------------------------------------------
    
    [1] Create new ccnet/seafile/seahub databases
    [2] Use existing ccnet/seafile/seahub databases
    
    [ 1 or 2 ] 1
    
    What is the host of mysql server?
    [ default "localhost" ]
    
    What is the port of mysql server?
    [ default "3306" ]
    
    What is the password of the mysql root user?
    [ root password ]
    
    verifying password of user root ...  done
    
    Enter the name for mysql user of seafile. It would be created if not exists.
    [ default "seafile" ]
    
    Enter the password for mysql user "seafile":
    [ password for seafile ]
    
    Enter the database name for ccnet-server:
    [ default "ccnet_db" ]
    
    Enter the database name for seafile-server:
    [ default "seafile_db" ]
    
    Enter the database name for seahub:
    [ default "seahub_db" ]
    
    ---------------------------------
    This is your configuration
    ---------------------------------
    
        server name:            Seafile-Server
        server ip/domain:       10.10.8.21
    
        seafile data dir:       /opt/seafile/seafile-data
        fileserver port:        8082
    
        database:               create new
        ccnet database:         ccnet_db
        seafile database:       seafile_db
        seahub database:        seahub_db
        database user:          seafile
    
    
    
    ---------------------------------
    Press ENTER to continue, or Ctrl-C to abort
    ---------------------------------
    Generating ccnet configuration ...
    
    Generating seafile configuration ...
    
    done
    Generating seahub configuration ...
    
    ----------------------------------------
    Now creating seafevents database tables ...
    
    ----------------------------------------
    ----------------------------------------
    Now creating ccnet database tables ...
    
    ----------------------------------------
    ----------------------------------------
    Now creating seafile database tables ...
    
    ----------------------------------------
    ----------------------------------------
    Now creating seahub database tables ...
    
    ----------------------------------------
    
    creating seafile-server-latest symbolic link ...  done
    
    
    
    
    -----------------------------------------------------------------
    Your seafile server configuration has been finished successfully.
    -----------------------------------------------------------------
    
    run seafile server:     ./seafile.sh { start | stop | restart }
    run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }
    
    -----------------------------------------------------------------
    If you are behind a firewall, remember to allow input/output of these tcp ports:
    -----------------------------------------------------------------
    
    port of seafile fileserver:   8082
    port of seahub:               8000
    
    When problems occur, Refer to
    
            https://download.seafile.com/published/seafile-manual/home.md
    
    for information.
    
    
    root@seafile-server:/opt/seafile/seafile-server-11.0.9#

    安装Seafile 

     

     

    查看代码
     root@seafile-server:/opt/seafile/seafile-server-11.0.9# vim /opt/seafile/conf/seahub_settings.py
    root@seafile-server:/opt/seafile/seafile-server-11.0.9# ./seafile.sh start
    
    Starting seafile server, please wait ...
    Seafile server started
    
    Done.
    root@seafile-server:/opt/seafile/seafile-server-11.0.9# ./seahub.sh start
    
    LC_ALL is not set in ENV, set to en_US.UTF-8
    Starting seahub at port 8000 ...
    
    ----------------------------------------
    It's the first time you start the seafile server. Now let's create the admin account
    ----------------------------------------
    
    What is the email for the admin account?
    [ admin email ] 1*******@qq.com
    
    What is the password for the admin account?
    [ admin password ]
    
    Enter the password again:
    [ admin password again ]
    
    ----------------------------------------
    Successfully created seafile admin
    ----------------------------------------
    
    Seahub is started
    
    Done.
    
    root@seafile-server:/opt/seafile/seafile-server-11.0.9#
posted @ 2024-06-21 09:16  Magiclala  阅读(122)  评论(0编辑  收藏  举报