Make a file with only contains the mysql root password and only root can read.
# ls -l /root/.mysqlpw
-rw------- 1 root root 7 2013-08-19 13:24 /root/.mysqlpw
You can import a database with
# mysql -u root -p`cat /root/.mysqlpw ` yourdatabase < databasedump.sql
or connect to you database and issue mysql commands
# mysql -u root -p`cat /root/.mysqlpw ` yourdatabase
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20460
Server version: 5.1.63-0ubuntu0.10.04.1 (Ubuntu)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| yourdatabase |
+--------------------+
3 rows in set (0.00 sec)
mysql> show tables;
...