Home  >  Q&A  >  body text

怎么连接wamp里面的MySQL数据库呀?

phpcn_u233phpcn_u2332761 days ago3308

reply all(3)I'll reply

  • 钟毅

    钟毅2017-10-04 17:33:59

    In cmd, c:>mysql -uroot -p123456 can be passed in one step. Generally, XWAMPP opens its own CMD under the WINDOWS platform, and you can use this command chain.

    reply
    0
  • 数据分析师

    数据分析师2017-09-30 23:39:19

    How to connect to the MySQL database in wamp? -PHP Chinese website Q&A-How to connect to the MySQL database in wamp? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 阿神

    阿神2016-12-24 13:12:49

    PHP要对数据库进行操作,首先要做的是与数据库建立连接,通常我们使用mysql_connect函数进行数据库连接,该函数需要指定数据库的地址,用户名及密码。

    $host = 'localhost';
    $user = 'code1';
    $pass = '';
    $link = mysql_connect($host, $user, $pass);

    PHP连接数据库的方式类似于直接在命令行下通过进行连接,类似:mysql -hlocalhost -ucode1 -p,当连接成功以后,我们需要选择一个操作的数据库,通过mysql_select_db函数来选择数据库。

    mysql_select_db('code1');

    通常我们会先设置一下当前连接使用的字符编码,一般的我们会使用utf8编码。

    mysql_query("set names 'utf8'");

    通过上面的步骤,我们就与数据库建立了连接,可以进行数据操作了。

    reply
    0
  • Cancelreply