first of all instead of using select * from table1, use select column1, column2, column3.. from table1. Look for the opportunity to introduce index in the table you are querying. use limit keyword if you are looking for any specific number of rows from the result set.
By below method if password is pass and user name is root
# [mysql dir]/bin/mysql -h hostname -u root -p pass
mysql> create database databasename;
mysql> show databases;
mysql> use databasename;