Directadmin restore error: “your_user” is not a valid username

I had this weird error when I tried to restore some directadmin accounts on new server. Majority of accounts were restored successfully, but some returned this error:

user1 is not a valid username
user2 is not a valid username

I tried many things and than found out that there is default setting for username length in directadmin configuration max_username_length. Default value is 10, so if your username of account that you are trying to restore is larger than 10 characters, error will be returned. You have to edit directadmin configuration and set this variable.

[root@mx ~]# vi /usr/local/directadmin/conf/directadmin.conf

then edit max_username_length to larger value. I my example 20.

max_username_length=20

Linux: restore all system permissions of your server

If you ever found your self in situation when you accidentally overwrite all permissions of your system, and everything stops working, then solution bellow may do the trick. This CentOS server was overwritten by wrong permissions through the whole system. Quick solution is to set up right permissions back. If you have backup of server that’s great. Otherwise you’ll have to set up new server with similar installation or do this on some other server with similar installation.

On “new” server, copy permissions of the whole system and save it to a file. You can also exclude dirs that you don’t need also.

find / -not -path "/proc*" -not -path "/dev*" -not -path "/sys*" -not -path "/var/www*" -exec stat -c "chmod %a %n;" {} \; > permissions.txt

On your “broken” server, rewrite all permissions:

cat permissions.txt | bash

Restore MSSQL database with new name

Restoring old MSSQL database to a new database with different name can be a little bit tricky on Windows. This was done on Windows Server 2008 with SQL Server 2008 Management Studio installed.

Here is how:

  1. Login to your SQL Server Management Studio.
  2. Create new database with name that you wish. In this case, we will create database name “new_database”. Just right click on “Databases” and then “New database”.
    mssqlrestpre1

  3. Select newly created database and right click on it, then select “Tasks -> Restore -> Database …” In “Destination for restore”, select database that we created in second step – new_database. Select it from drop down menu “To database”. In “Source for restore”, select  “From device” and then navigate to your database backup file from which you want to restore database.
    mssqlrestpre2 

    Also click on “Options” on left side of the window (Select a page). Then check “Overwrite the existing database”. Make sure that you pointed to right database files (Restore the database files as -> Restore As field). When done, click OK. Restore process will start.
    mssqlrestpre3 

  4. Your database should now be restored from your old database backup file to your newly created database new_database.
    mssqlrestpre4

How to save mysql query output into a file

Sometimes you may want to save output of some mysql query to a text file. Maybe even to Excel’s spreadsheet file so that you have more control with editing, sorting … MySQL offers many useful options there.

Below is an example on how to save some mysql query output to csv file. You can terminate fields with some key character which is super useful. This example has fields terminated with ; and lines with \n.

mysql> select firstname, lastname, email, phone from clients INTO OUTFILE '/tmp/outputfile.csv' FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n';

Just make sure that mysql has suitable permissions so that it will be able to write to a file – chmod 777.

Create dump of specific tables from mysql database

You can simply create backups of specific tables with mysqldump.

mysqldump -u  -p  databasename table1 table2 table3 ... > mysqldump_file.sql

© 2024 geegkytuts.net
Hosted by SIEL


About author