你如何在mySQL Workbench中创建一个可以用php连接的数据库?

你如何在mySQL Workbench中创建一个可以用php连接的数据库?

问题描述:

I am trying to create a blank database with mySQL Workbench that I can connect to with php. All this is on my local machine.

Here's what I think you do.

  1. Click on Create New EER Model
  2. Create a new Physical Schemata
  3. Give it a name
  4. Save Model to Current File
  5. I think the name you add here is the database name?

However I can't connect to that name in php. I have been trying this with a few options and one of them worked, but I can't see what's different about the ones that don't work.

There must be something very simple I am missing here.

eg this works:

$dbname = 'test';
$db = mysql_select_db($dbname);
echo '<br>db test is '.$db;

enter image description here

我正在尝试用mySQL Workbench创建一个空白数据库,我可以用php连接。 所有这一切都在我的本地机器上。 p>

这就是我的想法。 p>

  1. 点击Create New EER Model li>
  2. 创建新的物理架构 li>
  3. 为其命名 li>
  4. 将模型保存到当前文件 li>
  5. 我认为 你在这里添加的名称是数据库名称吗? li> ol>

    但是我无法在php中连接到该名称。 我一直尝试使用一些选项和 其中一个工作,但我看不出那些不起作用的不同。 p>

    这里必须有一些非常简单的东西。 p>

    例如,这可行: p>

      $ dbname ='test'; 
     $ db = mysql_select_db($ dbname); 
    echo'&lt; br&gt; db test 是'。$ db; 
      code>  pre> 
     
     

    p> div>

From the main screen, select the server under "SQL Development". You'll then see a window like the one below. Click the button I've highlighted with a red circle and follow the prompts.

Make sure to add a user to the database. This can be done under "Server Administration" under the "Accounts" tab. If you're not accessing it from the same machine hosting it, make sure the allowed host is set to % (or your IP). MySQL Workbench