MySql console – Most used commands

1. Login

mysql -u USERNAME -p

At the Enter Password prompt, type your password. When you type the correct password, the mysql> prompt appears.

2. List all databases

show databases;

3. Access a specific database

use DBNAME

4. List all tables

show tables;

5. The path to root config file

/etc/mysql/conf.d/my.cnf

6. Create user

To create a database user, type the following command. Replace username with the user you want to create, and replace password with the user’s password:

grant all privileges on *.* to 'user_name'@'localhost' identified by 'password';

For remote connection use % for domain name

 grant all privileges on *.* to 'user_name'@'%' identified by 'password';

7. Create and restore backup from mysqldump

mysqldump -u user_name -p database_name > /tmp/dump.sql
mysql -u user_name -p database_name < /tmp/dump.sql

8. Allow remote connection

Edit the config file /etc/mysql/conf.d/my.cnf by commenting the bind_address

#bind-address           = 127.0.0.1

Then restart mysql server

/etc/init.d/mysql restart

Then open the port 3306 on the machine

sudo iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

And test if from the remote computer

nc -z -v ip_address 3306

How to add subdomain in nginx server?

Follow these following steps to add a subdomain within Nginx server.

1. In the domain panel, add an A-record to point the new subdomain to your server

2. Register the new subdomain with Nginx server

sudo nano /etc/nginx/sites-available/youtube.hintdesk.com

3. Use this simple configuration for the newly created file

server {
        listen 80;

        root /var/www/html/apps/youtube;
        index index.html index.htm index.nginx-debian.html;

        server_name youtube.hintdesk.com www.youtube.hintdesk.com;

        location / {
                try_files $uri $uri/ /index.html?$args;
        }
}

4. To enable the configuration, make a symlink to the enabled sites

ln -s /etc/nginx/sites-available/youtube.hintdesk.com /etc/nginx/sites-enabled/youtube.hintdesk.com

5. The last thing to do is restart Nginx:

service nginx restart

6. If we activate SSL for our domain and receive the error ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY on Chrome. Then edit the ssl.conf with following settings

sudo nano /var/www/tetxua.com/conf/nginx/ssl.conf

And add following lines

ssl_ciphers "ECDHE+AES128:RSA+AES128:ECDHE+AES256:RSA+AES256:ECDHE+3DES:RSA+3DES";

Which is recommended by Cloudflare.

My online notes – Section 0006

Note 1: Sony Ericsson PC Suite for Z610i
http://www.megaupload.com/?d=V7II5C41

Note 2: Set autostart for program

private Boolean SchreibeinAutostart( String dateipfad )
{
    try
    {
        String samAccountName;
        {
            var currentWindowsIdentity = WindowsIdentity.GetCurrent( );
            if ( currentWindowsIdentity == null )
            {
                return false;
            }

            samAccountName = currentWindowsIdentity.Name;
        }

        var registrySecurity = new RegistrySecurity( );
        {
            registrySecurity.AddAccessRule( new RegistryAccessRule( samAccountName,
                    RegistryRights.WriteKey | RegistryRights.ChangePermissions, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow ) );
        }

        var targetRegistryKey = Registry.CurrentUser.CreateSubKey( "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\" );

        if ( targetRegistryKey == null )
        {
            return false;
        }

        targetRegistryKey.SetValue( dateipfad.Remove( 0, dateipfad.LastIndexOf( @"\" ) + 1 ), dateipfad );

    }
    catch ( Exception )
    {
        return false;
    }

    return true;
}

Continue reading My online notes – Section 0006

My online notes – Section 0005

Note 1: Impersonation for accessing network path

private void ApplyUserCredentials(string Share, string Domain, string Username, string Password)
{
	USE_INFO_2 useInfo = new USE_INFO_2();
	useInfo.ui2_local = string.Empty;
	useInfo.ui2_remote = Share;
	useInfo.ui2_password = Password;
	useInfo.ui2_asg_type = 0;    //disk drive
	useInfo.ui2_usecount = 1;
	useInfo.ui2_username = Username;
	useInfo.ui2_domainname = Domain;
	uint paramErrorIndex;

	uint returnCode = NetUseAdd(null, 2, ref useInfo, out paramErrorIndex);
	if (returnCode != 0)
	{
		throw new Win32Exception((int)returnCode);
	}
}

[DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern UInt32 NetUseAdd(string UncServerName,UInt32 Level, ref USE_INFO_2 Buf,  out UInt32 ParmError);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct USE_INFO_2
{
	internal string ui2_local;
	internal string ui2_remote;
	internal string ui2_password;
	internal UInt32 ui2_status;
	internal UInt32 ui2_asg_type;
	internal UInt32 ui2_refcount;
	internal UInt32 ui2_usecount;
	internal string ui2_username;
	internal string ui2_domainname;
}

Continue reading My online notes – Section 0005

My online notes – Section 0004

Note 1: Proxy of HttpWebRequest for uploading

HttpWebRequest HttpRequest = (HttpWebRequest)WebRequest.Create(this.fullUrl);
<system.net>
    <defaultProxy enabled ="false">
		<proxy autoDetect ="True"/>
    </defaultProxy>
</system.net>

Note 2: Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control for page loading
http://msdn.microsoft.com/en-us/library/15a31akc.aspx

Continue reading My online notes – Section 0004