Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Database Server
  • Search

Error: db_user

Questions regarding the Database Server
MySQL, PostgreSQL, MariaDB, Percona Server, phpMyAdmin, phpPgAdmin
Post Reply
  • Print view
Advanced search
6 posts • Page 1 of 1
celsowebmax
Posts: 9
Joined: Sun May 01, 2016 12:10 am

Error: db_user
  • Quote

Post by celsowebmax » Tue May 24, 2016 2:30 am

Hi Guys...
I have one domain very long...more than 17 characters. And I am unable to create the database because of the prefix_
How can I solve this problem?
Is there any way to remove this character limit on dbuser?
Thank in advance.
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Error: db_user
  • Quote

Post by skurudo » Tue May 24, 2016 2:22 pm

16 symbols it's MySQL limit.
viewtopic.php?t=9945#p35765

It's not recommended, but you can change this limit:
viewtopic.php?t=5937
viewtopic.php?f=14&t=4927#p14320
Top

celsowebmax
Posts: 9
Joined: Sun May 01, 2016 12:10 am

Re: Error: db_user
  • Quote

Post by celsowebmax » Tue May 24, 2016 2:27 pm

I see all these topics. But not solved 100% for me.
The solution was recreate the users with only 6 characters.
Thank very much for you attention my friend.
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Error: db_user
  • Quote

Post by skurudo » Fri Jun 10, 2016 12:47 pm

celsowebmax wrote:I see all these topics. But not solved 100% for me.
The solution was recreate the users with only 6 characters.
Added idea on bugtracker:
https://bugs.vestacp.com/issues/258

Please vote for this feature.
Top

Elizine
Posts: 50
Joined: Wed Aug 12, 2015 12:11 pm
Contact:
Contact Elizine
Website

Re: Error: db_user
  • Quote

Post by Elizine » Sat Jul 02, 2016 11:21 am

Edit main.sh ( /usr/local/vesta/func ) line 811 to This:
dbuser) validate_format_dbuser "${arg:0:16}" 'db_user';;
AND
in v-add-database (/usr/local/vesta/bin/) line 77 to This:
str="DB='$database' DBUSER='${dbuser:0:16}' MD5='$md5' clear=$dbpass HOST='$host' TYPE='$type'"

That takes care of the validation and shortens the username to the MAX for mysql of 16 chars whilst keeping inline with naming convention as I understand it (username_DBuser) to keep tabs on users DBs...
Probably the best solution would be to edit the front end and make the validation there.. but this works just fine it will shorten the name by latter part if to long to 16 chars.
Top

Fleuv
Posts: 18
Joined: Thu May 28, 2015 4:27 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: Error: db_user
  • Quote

Post by Fleuv » Mon Jul 22, 2019 11:28 am

Username shortening is not the way to go in case of usernames like:

johnnydoesgood
johnnydoesverygood

If usernames will be shortened to 8 (thus resulting name will be: johnnydo) it will cause conflicts in database creation:
  • johnnydoesgood creates dbuser "johnnydo_mydb" what will be successful and johnnydoesverygood won't be able to access or know about it.
  • johnnydoesverygood creates dbuser "johnnydo_site" what will be successful and johnnydoesgood won't be able to access or know about it.
  • johnnydoesverygood creates a second dbuser called "johnnydo_mydb" what will be successful. However the johnnydoesgood user will not be able to access the database anymore with the password used to create the user, unless johnnydoesgood updates the password what will cause the password not to work for johnnydoesverygood. Or mysql will not allow recreation of the database and the database won't be created in mysql however I don't see any error handling for this one in vesta.
Either way I would suggest increasing the max dbuser char length as the only suitable option. Here is a complete guide on how to achieve that including necessary changes to VestaCP. Note in this case the char limit is extended from 16 to 32 chars.
  • Log in to mysql as root on your (database) server and execute the following queries:

    Code: Select all

    USE mysql;
    ALTER TABLE user MODIFY user CHAR(32);
    ALTER TABLE db MODIFY user CHAR(32);
    FLUSH PRIVILEGES;
    
  • Open /usr/local/vesta/func/main.sh and search for a part of the error message what displayed on the front end, e.g. "mysql username can be". You will find a conditional check nearby, this checks if the username is within a certain length, with my current vesta version this is how I updated the code:

    Code: Select all

    if [ 33 -le ${#1} ]; then
        check_result $E_INVALID "mysql username can be up to 32 characters long"
    fi
    
That's it.

Note this is a temporary fix, suggested way of fixing this:
  • Query the mysql.user table with the describe command and lookup the user attribute's max length.
  • Cache this max length.
  • Every time the validation is executed for creating a new database this cached length will be used to validate the max length.
  • A con for this dynamic solution might be that downsizing of the max length can cause conflicts, so don't forget to make a restriction to down sizing.
Top


Post Reply
  • Print view

6 posts • Page 1 of 1

Return to “Database Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password