SOHO : Small Office Home Office
Freeware - Opensource software tips, tricks, tweaks & fixes for managing, securing, improving the performance of SOHO Desktop, Laptop, Networks

Sunday, November 21, 2010

How to disable CPU core(s) in a multicore machine?

Method 1: "Change the Bootargs"

Change the boot arguments to use ony n number of CPU cores instead of m cores which are actually present, PROVIDED n

a) Add "maxcpus=n" in the bootargs during boot time:
 linux    /boot/vmlinuz-2.6.31-21-generic root=UUID=2ebbae04-b641-44e9-935f-8964159d79cb ro   quiet splash maxcpus=n
This will not be persistent across subsequent boots.

b) To make it permanent, modify/edit /etc/default/grub and add "maxcpus=n" in the following line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash maxcpus=n"

Method 2: "Enable/Disable a CPU core on the fly"

On a Linux machine you can get the CPU information from /proc/cpuinfo file. On a dual core machine, you will get the output like this:
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel

processor : 1
vendor_id : GenuineIntel
 To disable a core run the following command on a Ubuntu machine:
$ sudo sh -c "echo 'n' > /sys/devices/system/cpu/cpu1/online"

 Test if the core is disabled or not, check the /proc/cpuinfo file.
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel

Now which method to choose from?

Method 1. is recommended since maxcpus=n should optimize some locks and instructions.
Choose Method 2. if you can't afford to restart your machine.

Happy Hacking!!

P.S. These instructions are only tested on a Dual core machine so I have no clue how they will behave on a multi-core(>2) environment.
Continue Reading...

Wednesday, November 10, 2010

Add user to mysql, commandline method

Solution: Here's an example of what I did recently to (a) create a new MySQL database and then (b) add a new MySQL user account to work with that database. As usual, the database name, username, and password have been changed.
First, from my Unix prompt, I log into my MySQL database with the mysql command line client:
unix> mysql -u root -p
(here I enter 'my_root_password' to get through the mysql prompt)

Next, I create my new MySQL database with the "create database" command:
mysql> create database my_database;
And now I create a MySQL user account, giving the user account all the priviliges it needs to "own" this database, with the MySQL grant command. Note that I assign both the username and password when I add this MySQL user:
       ON my_database.* 
       TO 'my_user'@'localhost'
       IDENTIFIED BY 'my_password' 
Of course you can put that entire MySQL GRANT command on one line; I just put it on multiple lines here so it would be easier to read. Using this GRANT command is how you create a MySQL user account.
Update: Please see the Comments section below for an additional "MySQL add user" example that uses the "MySQL grant" command.

Note about this MySQL user account and "localhost"

It's important to note when I create this MySQL user, I'm giving the user access to this MySQL database from the computer system known as "localhost". This works fine when you're accessing this database with this new MySQL user account from the local computer system, but if you're going to access this database from another computer system, you'll need to specify the IP address of that remote system here instead of "localhost".
Continue Reading...

MySQL command to show list of databases on server

Q. I am new to MySQL database server. How do I show the list of databases on my server? Is there any good GUI frontend exists for the same?

A. You can use mysql command to connect to mysql server and list available databases.

Task: Mysql list databases

mysql is a simple command-line tool. mysql is command line and it is very easy to use. Invoke it from the prompt of your command interpreter as follows:
$ mysql

You may need to provide mysql username, password and hostname, use:
$ mysql --user=your-user-name --password=your-password

To list database type the following command

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
2 rows in set (0.00 sec)
information_schema and mysql are name of databases. To use these database and to list available tables type the following two commands:
mysql> use mysql;Output:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
Now list tables:
mysql> show tables;Output:
| Tables_in_mysql           |
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
17 rows in set (0.00 sec)


GUI tools

Since you are new to MySQL, it is better to use GUI tools. Please refer previous article about "GUI Tools for managing MySQL databases server"
Continue Reading...

Recover MySQL root Password

You can recover MySQL database server password with following five easy steps.

Step # 1: Stop the MySQL server process.
Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password.
Step # 3: Connect to mysql server as the root user.
Step # 4: Setup new mysql root account password i.e. reset mysql password.
Step # 5: Exit and restart the MySQL server.
Here are commands you need to type for each step (login as the root user):

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:

# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/
mysqld_safe[6186]: ended

[1]+  Done                    mysqld_safe --skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p
Continue Reading...

Mysql change root password by commandline

How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?
Setting up mysql password is one of the essential tasks. By default root user is MySQL admin account. Please note that the Linux / UNIX login root account for your operating system and MySQL root are different. They are separate and nothing to do with each other (indeed some admin removes root account and setup admin as mysql super user).

mysqladmin command to change root password

If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:
$ mysqladmin -u root password NEWPASSWORD
However, if you want to change (or update) a root password, then you need to use following command
$ mysqladmin -u root -p'oldpassword' password newpass
For example, If old password is abc, and set new password to 123456, enter:
$ mysqladmin -u root -p'abc' password '123456'

Change MySQL password for other user

To change a normal user password you need to type (let us assume you would like to change password for john)
$ mysqladmin -u john -p oldpassword password newpass

Changing MySQL root user password using MySQL sql command

This is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user john:
1) Login to mysql server, type following command at shell prompt:
$ mysql -u root -p
2) Use mysql database (type command at mysql> prompt):
mysql> use mysql;
3) Change password for user john:
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='john';
4) Reload privileges:
mysql> flush privileges;
mysql> quit
This method you need to use while using PHP or Perl scripting.
Continue Reading...

How to add shopping cart to blogger?

The easiest way to add a shopping cart is to use Paypal Merchant Tools. Of course in order to make use of this service, you will need a Paypal account if you don't already have one. Signing up is free and easy. Plus by making use of Paypal Merchant Tools, you can accept credit card payments.

3 Steps to add shopping in blogger

  1. You will have to prepare your post. Add photographs, description, prices, etc.
  2. Sign into your Paypal account.
    • Click on the Merchant Tool tab.
    • At the right sidebar, click on "Paypal Shopping Cart"
    • Enter the details like Item Name/Service, Item ID/Number (optional), Price of Item/Service you want to sell, Currency, etc.
    • Then either tick the Paypal "Add to Cart" button or if you have your own button hosted on the web, enter its URL.
    • Click the "Create button now"  at the bottom of the page
    • Two  HTML script will be generated - one for the "Add to Shopping Cart" button and another for the "View Cart" button. Copy the HTML scripts and paste them in the appropriate places in your Post Editor Window.
    •  Add further buttons if required
  3. Publish the post.
Continue Reading...