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

Change default database prefix or show other databases

Questions regarding the Database Server
MySQL, PostgreSQL, MariaDB, Percona Server, phpMyAdmin, phpPgAdmin
Post Reply
  • Print view
Advanced search
8 posts • Page 1 of 1
spacing
Posts: 22
Joined: Thu Dec 03, 2015 9:44 pm

Change default database prefix or show other databases
  • Quote

Post by spacing » Wed Feb 24, 2016 4:33 pm

So I recently posted this issue on this forum and just now discovered what was the problem.

I just remembered when I setup my site originally I imported the db from other host with a different prefix and restored it through the root phpmyadmin user not the admin user, thus leading to vesta not recognizing any db and showing the only existing one as empty.

Is there any way vesta can recognize this db created by the root user and also is there any way I can change the default prefix for db names on vesta?
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Change default database prefix or show other databases
  • Quote

Post by tjebbeke » Wed Feb 24, 2016 6:15 pm

The prefix is always the username.

Vesta has it own config files per user. To add your self created database you can edit the database config file of the specific user.
/usr/local/vesta/data/users/{username}/db.conf
DB='user_dbname' DBUSER='user_dbuser' MD5='md5password' HOST='localhost' TYPE='mysql' CHARSET='UTF8' U_DISK='1' SUSPENDED='no' TIME='09:21:29' DATE='2015-01-16'
Top

shankarnewton
Posts: 8
Joined: Wed Apr 01, 2015 4:09 am

Re: Change default database prefix or show other databases
  • Quote

Post by shankarnewton » Sat Feb 27, 2016 5:36 am

Hi Guys,
is there any way to change the config so that each time when i create a new database, the prefix is not included.
I feel somethings prefix are helpful, but sometimes they messup and am unable to have a dedicated db seperately for a single application.
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Change default database prefix or show other databases
  • Quote

Post by tjebbeke » Sat Feb 27, 2016 9:21 am

shankarnewton wrote:Hi Guys,
is there any way to change the config so that each time when i create a new database, the prefix is not included.
I feel somethings prefix are helpful, but sometimes they messup and am unable to have a dedicated db seperately for a single application.
No, it isn't possible. When you don't take the username as the prefix, every user can add the same database. Of course, there is an error handler to avoid this. But, I don't think it's a good idea when you have a lot of users.
Top

spacing
Posts: 22
Joined: Thu Dec 03, 2015 9:44 pm

Re: Change default database prefix or show other databases
  • Quote

Post by spacing » Sun Feb 28, 2016 4:09 pm

tjebbeke wrote:The prefix is always the username.

Vesta has it own config files per user. To add your self created database you can edit the database config file of the specific user.
/usr/local/vesta/data/users/{username}/db.conf
DB='user_dbname' DBUSER='user_dbuser' MD5='md5password' HOST='localhost' TYPE='mysql' CHARSET='UTF8' U_DISK='1' SUSPENDED='no' TIME='09:21:29' DATE='2015-01-16'
I actually ended up moving my existing db to the default admin_ prefix one but vestaCP is still showing the admin_dbname database as 0mb and not recognizing it properly despite it being full (300Mb +) on phpmyadmin, any way to fix this?
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Change default database prefix or show other databases
  • Quote

Post by tjebbeke » Mon Feb 29, 2016 10:52 am

Vesta use this code to check the usage:

Code: Select all

get_mysql_disk_usage() {
    mysql_connect $HOST
    query="SELECT SUM( data_length + index_length ) / 1024 / 1024 \"Size\"
        FROM information_schema.TABLES WHERE table_schema='$database'"
    usage=$(mysql_query "$query" |tail -n1)
    if [ "$usage" == 'NULL' ] || [ "${usage:0:1}" -eq '0' ]; then
        usage=1
    fi
    export LC_ALL=C
    usage=$(printf "%0.f\n"  $usage)
}
You can debug what the output is of the query.

Code: Select all

SELECT SUM( data_length + index_length ) / 1024 / 1024 \"Size\" FROM information_schema.TABLES WHERE table_schema='admin_dbname'
Top

spacing
Posts: 22
Joined: Thu Dec 03, 2015 9:44 pm

Re: Change default database prefix or show other databases
  • Quote

Post by spacing » Thu Mar 03, 2016 5:23 pm

tjebbeke wrote:Vesta use this code to check the usage:

Code: Select all

get_mysql_disk_usage() {
    mysql_connect $HOST
    query="SELECT SUM( data_length + index_length ) / 1024 / 1024 \"Size\"
        FROM information_schema.TABLES WHERE table_schema='$database'"
    usage=$(mysql_query "$query" |tail -n1)
    if [ "$usage" == 'NULL' ] || [ "${usage:0:1}" -eq '0' ]; then
        usage=1
    fi
    export LC_ALL=C
    usage=$(printf "%0.f\n"  $usage)
}
You can debug what the output is of the query.

Code: Select all

SELECT SUM( data_length + index_length ) / 1024 / 1024 \"Size\" FROM information_schema.TABLES WHERE table_schema='admin_dbname'
I get this error
Image
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Change default database prefix or show other databases
  • Quote

Post by tjebbeke » Thu Mar 03, 2016 9:57 pm

try:
SELECT SUM( data_length + index_length ) / 1024 / 1024 "Size" FROM information_schema.TABLES WHERE table_schema='admin_dbname'
Top


Post Reply
  • Print view

8 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