SIGN IN / UP
    opened image

    In the VestaCP panel, when creating a new database, the user prefix is automatically added.
    The database prefix is useful, it helps to better navigate when viewing all the created databases and slightly improves the security of the site, since attackers will have to guess not only the mysql user, but also the panel user under which the database was created.
    We highly discourage using simple usernames and passwords on the server as this puts your data at risk.

    We connect to the server via ssh using the data from the root user;

    Copy the vesta script file, which is responsible for creating databases;

    # cp /usr/local/vesta/bin/v-add-database /usr/local/vesta/bin/v-add-database-no_prefix


    Open a new file (for example using: vi, vim, nano);

     

    # vi /usr/local/vesta/bin/v-add-database-no_prefix


    We are interested in lines 20 and 21; they need to be edited and saved;
    Before:

    database="$user"_"$2"
    dbuser="$user"_"$3"

    After:

    database=$2
    dbuser=$3


    Now we can execute it by specifying the necessary parameters;

     

    # v-add-database-no_prefix USER DATABASE DBUSER DBPASS
    • USER - VestaCP panel user
    • DATABASE - database name
    • DBUSER - mysql user for database
    • DBPASS is the password of the specified mysql user

    If you specify an existing database user, then the password for that user will be changed.

    Done. Now we can create databases and users without a prefix when needed.