How to do interactive with the prompt this way in PHP?

Posted by user198729 on Stack Overflow See other posts from Stack Overflow or by user198729
Published on 2010-04-10T05:15:54Z Indexed on 2010/04/10 5:23 UTC
Read the original article Hit count: 146

Filed under:
|
C:\>mysql -uroot -padmin
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.37-community-nt-log MySQL Community Edition (GPL)

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

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| attendance         |
| fusionchartsdb     |
| mysql              |
| sugarcrm           |
| test               |
+--------------------+
6 rows in set (0.09 sec)

mysql> use mysql;
Database changed
mysql>

So I want to start a process by mysql -uroot -padmin,and in that process I want to run these statements:

 show databases
 use mysql
 insert xxx (..) values (..)

How to do it in PHP?

© Stack Overflow or respective owner

Related posts about php

Related posts about exec