Criar um arquivo contendo apenas a senha root do mysql e somente o root pode ler.
# ls -l /root/.mysqlpw
-rw------- 1 root root 7 2013-08-19 13:24 /root/.mysqlpw
Você pode importar um banco de dados com
# mysql -u root -p`cat /root/.mysqlpw ` yourdatabase < databasedump.sql
ou conecte-se ao banco de dados e emita comandos mysql
# 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;
...