Want to subscribe to topics you're interested in?
Become a Member

centmin.sh Create MySQL User and Database

Discussion in 'Bug Reports' started by Itworx4me, Sep 17, 2025.

  1. Itworx4me

    Itworx4me Premium Member Premium Member

    339
    35
    28
    Mar 14, 2017
    Ratings:
    +65
    Local Time:
    4:53 PM
    Nginx 1.27.4
    MariaDB 10.6.21
    CentOS Version: Rocky Linux 8

    Centmin Mod Version Installed:
    Code (Text):
    # cminfo versions
    
    Installed:
      tcpdump-14:4.9.3-5.el8.x86_64                                                                                                                                                                                                        
    
    
    1st:
    130.00beta01.b516 #Sun Jan 28 03:02:04 UTC 2024
    ..
    last 10:
    140.00beta01.b246 #Mon Sep  1 21:57:28 UTC 2025
    140.00beta01.b246 #Tue Sep  2 13:08:19 UTC 2025
    140.00beta01.b247 #Tue Sep  2 13:10:11 UTC 2025
    140.00beta01.b248 #Sun Sep 14 04:06:01 UTC 2025
    140.00beta01.b248 #Sun Sep 14 04:43:33 UTC 2025
    140.00beta01.b248 #Sun Sep 14 13:38:50 UTC 2025
    140.00beta01.b248 #Sun Sep 14 14:01:15 UTC 2025
    140.00beta01.b248 #Sun Sep 14 23:48:48 UTC 2025
    140.00beta01.b248 #Mon Sep 15 00:09:24 UTC 2025
    140.00beta01.b249 #Tue Sep 16 14:15:02 UTC 2025



    Nginx Version Installed:
    Code (Text):
    nginx version: nginx/1.29.1 (010925-215809-rockylinux8-b1c9373)
    built by gcc 13.3.1 20240611 (Red Hat 13.3.1-2) (GCC)
    built with OpenSSL 1.1.1k  FIPS 25 Mar 2021
    TLS SNI support enabled
    configure arguments: --with-ld-opt='-Wl,-E -L/usr/local/zlib-cf/lib -L/usr/local/nginx-dep/lib -ljemalloc -Wl,-z,relro,-z,now -Wl,-rpath,/usr/local/zlib-cf/lib:/usr/local/nginx-dep/lib -pie -flto=2 -flto-compression-level=3 -B/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld.gold -Wl,-Bsymbolic-functions -Wl,--as-needed' --with-cc-opt='-I/usr/local/zlib-cf/include -I/usr/local/nginx-dep/include -m64 -march=native -fPIC -g -O3 -fstack-protector-strong -flto=2 -flto-compression-level=3 -B/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld.gold --param=ssp-buffer-size=4 -Wformat -Wno-pointer-sign -Wimplicit-fallthrough=0 -Wno-implicit-function-declaration -Wno-cast-align -Wno-builtin-declaration-mismatch -Wno-deprecated-declarations -Wno-int-conversion -Wno-unused-result -Wno-vla-parameter -Wno-maybe-uninitialized -Wno-return-local-addr -Wno-array-parameter -Wno-alloc-size-larger-than -Wno-address -Wno-array-bounds -Wno-discarded-qualifiers -Wno-stringop-overread -Wno-stringop-truncation -Wno-missing-field-initializers -Wno-unused-variable -Wno-format -Wno-error=unused-result -Wno-missing-profile -Wno-stringop-overflow -Wno-free-nonheap-object -Wno-discarded-qualifiers -Wno-bad-function-cast -Wno-dangling-pointer -Wno-array-parameter -fcode-hoisting -Wno-cast-function-type -Wno-format-extra-args -Wp,-D_FORTIFY_SOURCE=2' --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --build=010925-215809-rockylinux8-b1c9373 --with-compat --without-pcre2 --with-http_stub_status_module --with-http_secure_link_module --with-libatomic --with-http_gzip_static_module --with-http_sub_module --with-http_addition_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --with-stream --with-stream_ssl_module --with-http_realip_module --add-dynamic-module=../ngx-fancyindex-0.5.2 --add-module=../ngx_cache_purge-2.5.3 --add-dynamic-module=../ngx_devel_kit-0.3.2 --add-dynamic-module=../set-misc-nginx-module-0.33 --add-dynamic-module=../echo-nginx-module-0.63 --add-module=../redis2-nginx-module-0.15 --add-module=../ngx_http_redis-0.4.0-cmm --add-module=../memc-nginx-module-0.20 --add-module=../srcache-nginx-module-0.33 --add-dynamic-module=../headers-more-nginx-module-0.37 --with-pcre-jit --with-zlib=../zlib-cloudflare-1.3.3 --with-zlib-opt=-fPIC --with-http_ssl_module --with-http_v2_module

    PHP Version Installed:
    Code (Text):
    PHP 8.4.12 (cli) (built: Sep  1 2025 22:03:52) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.4.12, Copyright (c) Zend Technologies
        with Zend OPcache v8.4.12, Copyright (c), by Zend Technologies


    MariaDB MySQL Version Installed:
    Code (Text):
    mysqladmin  Ver 10.0 Distrib 10.6.23-MariaDB, for Linux on x86_64
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Server version          10.6.23-MariaDB
    Protocol version        10
    Connection              Localhost via UNIX socket
    UNIX socket             /var/lib/mysql/mysql.sock
    Uptime:                 15 days 1 hour 56 min 56 sec
    
    Threads: 16  Questions: 177905743  Slow queries: 0  Opens: 14710  Open tables: 1270  Queries per second avg: 136.533


    When was last time updated Centmin Mod code base ? : Every 6 Hours

    Persistent Config: Do you have any persistent config file options set in /etc/centminmod/custom_config.inc ?
    Code (Text):
    DEVTOOLSETTEN='n'
    DEVTOOLSETELEVEN='n'
    DEVTOOLSETTWELVE='y'
    SELFSIGNEDSSL_ECDSA='y'
    PHPFINFO='y'
    PHP_OVERWRITECONF='n'
    PYTHON_INSTALL_ALTERNATIVES='y'
    MYSQLADMIN_SHELL='y'
    LETSENCRYPT_DETECT='y'
    CF_DNSAPI_GLOBAL='y'
    CF_Token="........"
    CF_Account_ID="......."
    ENABLE_MARIADBTENFOURUPGRADE='y'
    ENABLE_MARIADBTENFIVEUPGRADE='y'
    ENABLE_MARIADBTENSIXUPGRADE='y'
    



    @eva2000 When creating option #1 of the Database management system. It doesn't assign the user to the database. Can you also check that the other option function correctly. Also it doesn't show the correct creation date for user or database. I had the hardest time getting a user assigned to a database using 2, 3, 4.
    Screenshot 2025-09-16 071542.png
    Thanks,
    Itworx4me
     
    Last edited: Sep 17, 2025
  2. eva2000

    eva2000 Administrator Staff Member

    58,893
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    9:53 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    Please fill in any relevant information that applies to you:
    • CentOS Version: i.e. CentOS 7 64bit / AlmaLinux / Rocky Linux 8/9 ?
    • Centmin Mod Version Installed: i.e. 132.00stable or 140.00beta01 or 131.00stable or 140.00beta01. Run command:
      Code (Text):
      cminfo versions
    • Nginx Version Installed: i.e. 1.27.5 or 1.29.1 ? Run command and post output in QUOTE BBCODE tags:
      Code (Text):
      nginx -V
    • PHP Version Installed: i.e. 7.3.33, 7.4.33, 8.0.30, 8.1.33, 8.2.29, 8.3.25, 8.4.11. Run command and post output in CODE/CODEB BBCODE tags:
      Code (Text):
      php -v
    • MariaDB MySQL Version Installed: i.e. 10.3.xx or 10.4.xx or 10.6.xx or 10.11.xx. Run command and post output in CODE/CODEB BBCODE tags:
      Code (Text):
      mysqladmin ver
    • When was last time updated Centmin Mod code base ? : i.e. run centmin.sh menu option 23 submenu option 2 or cmupdate command
    • Persistent Config: Do you have any persistent config file options set in /etc/centminmod/custom_config.inc ? You can check via this command:
      Code (Text):
      cat /etc/centminmod/custom_config.inc
      

      Post output in CODE or CODEB bbcode tags.
    Sensitive Info

    For /etc/centminmod/custom_config.inc persistent file contents, you may have setup private sensitive information i.e. API keys, etc so filter those out if applicable before posting publicly on forums etc.
     
  3. Itworx4me

    Itworx4me Premium Member Premium Member

    339
    35
    28
    Mar 14, 2017
    Ratings:
    +65
    Local Time:
    4:53 PM
    Nginx 1.27.4
    MariaDB 10.6.21
    Updated first post
     
  4. eva2000

    eva2000 Administrator Staff Member

    58,893
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    9:53 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    Just tried centmin.sh menu option 6 submenu option 1 and worked for me with MariaDB 10.6.23

    Code (Text):
    ----------------------------------------------------------------
     MySQL User Database Management Sub Menu
    ----------------------------------------------------------------
     Command Line Version community.centminmod.com/threads/543/
    ----------------------------------------------------------------
    1). Create MySQL User and Database
    2). Add Database to Existing MySQL User
    3). Add Existing Database to Existing MySQL User
    4). Add Existing Database to New MySQL User
    5). Change MySQL User Password
    6). Delete MySQL User
    7). Show Grants for MySQL User
    8). Create Global MySQL User (access to all databases)
    9). Create Multiple MySQL Databases and Users from File
    10). Delete MySQL Database
    11). List All MySQL Databases and Users
    12). Return to Main Menu
    ----------------------------------------------------------------
    Enter option [ 1 - 12 ]: 1
    Do you want to proceed with this option? [y/n]: y
    --------------------------------------------------------------
    MySQL Admin
    --------------------------------------------------------------
    --------------------------------------------------------------
    

    Code (Text):
    ---------------------------------
    Create MySQL username:
    ---------------------------------
     Enter new MySQL username you want to create: user01
     Enter new MySQL username's password: pass01
    ---------------------------------
    Create MySQL database:
    ---------------------------------
     Enter new MySQL database name: db01
    
    Grants for user01@localhost
    GRANT USAGE ON *.* TO `user01`@`localhost` IDENTIFIED BY PASSWORD '*C622305CD165FFAA9E89A3A6B60BDDCC5A5FD729'
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `db01`.* TO `user01`@`localhost`
    
    Ok: MySQL user: user01 MySQL database: db01 created successfully

    test login
    Code (Text):
    mysql -u user01 -ppass01 db01
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2643
    Server version: 10.6.23-MariaDB MariaDB Server
    
    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 [db01]> 

    The log file for the menu run is at /root/centminlogs/centminmod_141.00beta01.b019_170925-000411_mysqladminshell.log and shows the same.
    Code (Text):
    ls -lahrt /root/centminlogs/ | grep 'mysqladminshell.log'
    -rw-r--r--   1 root root 3.7K Sep 17 00:05 centminmod_141.00beta01.b019_170925-000411_mysqladminshell.log
    

    db01 created database on file date/time
    Code (Text):
    ls -lahrt /var/lib/mysql/ | grep db01
    drwx------   2 mysql mysql   20 Sep 17 00:05 db01
    

    How are you checking correct creation date for user or database? Server by default uses UTC timezone unless you changed it
     
  5. eva2000

    eva2000 Administrator Staff Member

    58,893
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    9:53 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    centmin.sh menu option 6 submenu option 2 also works
    Code (Text):
    ----------------------------------------------------------------
     MySQL User Database Management Sub Menu
    ----------------------------------------------------------------
     Command Line Version community.centminmod.com/threads/543/
    ----------------------------------------------------------------
    1). Create MySQL User and Database
    2). Add Database to Existing MySQL User
    3). Add Existing Database to Existing MySQL User
    4). Add Existing Database to New MySQL User
    5). Change MySQL User Password
    6). Delete MySQL User
    7). Show Grants for MySQL User
    8). Create Global MySQL User (access to all databases)
    9). Create Multiple MySQL Databases and Users from File
    10). Delete MySQL Database
    11). List All MySQL Databases and Users
    12). Return to Main Menu
    ----------------------------------------------------------------
    Enter option [ 1 - 12 ]: 2
    Do you want to proceed with this option? [y/n]: y
    --------------------------------------------------------------
    MySQL Admin
    --------------------------------------------------------------
    --------------------------------------------------------------
    

    Code (Text):
    -------------------------------------------------------------------------
    Add new database name to existing MySQL username:
    -------------------------------------------------------------------------
     Enter existing MySQL username you want to add new database name to: user01
    ---------------------------------
    Create MySQL database:
    ---------------------------------
     Enter new MySQL database name: db02
    
    Grants for user01@localhost
    GRANT USAGE ON *.* TO `user01`@`localhost` IDENTIFIED BY PASSWORD '*C622305CD165FFAA9E89A3A6B60BDDCC5A5FD729'
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `db01`.* TO `user01`@`localhost`
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `db02`.* TO `user01`@`localhost`
    
    Ok: New MySQL database: db02 assigned to existing MySQL user: user01


    Code (Text):
    mysql -u user01 -ppass01 db02
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2655
    Server version: 10.6.23-MariaDB MariaDB Server
    
    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 [db02]> 
     
  6. Itworx4me

    Itworx4me Premium Member Premium Member

    339
    35
    28
    Mar 14, 2017
    Ratings:
    +65
    Local Time:
    4:53 PM
    Nginx 1.27.4
    MariaDB 10.6.21
    Before I remembered that there was a menu option to add a user and database to the system, I tried using the following code:
    Code (Text):
    cmdir
    cd addons
    ./mysqladmin_shell.sh createuserdb YOURDBNAME YOURDBUSERNAME YOURDBPASSWORD
    

    That attempt failed to create the database. I recalled the menu options, but at first none of the menu items seemed to work for me. I wasn’t sure if my earlier command had caused the issue. However, when I tested again today, everything worked as expected.
     
  7. eva2000

    eva2000 Administrator Staff Member

    58,893
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    9:53 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    addons/mysqladmin_shell.sh is the underlying tool used for centmin.sh menu option 6, so should end up with same results

    see commands for addons/mysqladmin_shell.sh at https://community.centminmod.com/threads/mysqladmin_shell-sh-shell-based-addon.543/ where

    • createuserdb - creates new user and database
    • setuserdb - Create an individual MySQL user and database or assign a new database to an existing MySQL user.
    Code (Text):
    ./mysqladmin_shell.sh setuserdb
    --------------------------------------------------------------
    Basic MySQL Admin - create mysql user & databases
    --------------------------------------------------------------
    --------------------------------------------------------------
     1. Create a new MySQL username & new MySQL database
     2. Add a new database name to existing MySQL username
     3. Add an existing database name to existing MySQL username
     4. Add an existing database name to new MySQL username
     5. Exit
     Enter option number 1-5:
    

    Code (Text):
    addons/mysqladmin_shell.sh
    
    Usage: addons/mysqladmin_shell.sh {multidb|setglobaluser|setuserdb|setpass|createuserdb|deluser|showgrants}
    
    Options:
    
      multidb
        Multiple MySQL database/user creation mode. Pass a file name containing
        db, user, and pass as 3-column entries.
    
      setglobaluser
        Create a MySQL username with access to all databases on the server
        without SUPER ADMIN privileges (non-root).
    
      setuserdb
        Create individual MySQL usernames and databases or assign a new
        database to an existing MySQL username.
    
      setpass
        Change MySQL username password.
    
      createuserdb
        Unattended create individual MySQL username & databases. Fields
        required are dbname, dbuser, and dbpass.
    
      deluser
        Delete MySQL usernames.
    
      showgrants
        Show existing MySQL username granted privileges.


    there should be logged logs in /root/centminlogs if you need to inspect past centmin.sh menu or addons/tools runs output etc for troubleshooting

    Code (Text):
    ls -lahrt /root/centminlogs