官术网_书友最值得收藏!

Creating a database

Before creating a table, we must ensure that we have a database for which the MySQL server's administrator has given us the CREATE privilege. The following possibilities exist:

  • The administrator has already created a database for us, and we see its name in the navigation panel; we don't have the right to create an additional database.
  • We have the right to create databases from phpMyAdmin.
  • We are on a shared host, and the host provider has installed a general web interface (for example, cPanel) to create MySQL databases and accounts; in this case, we should visit this web interface now and ensure we have created at least one database and one MySQL account.

The Databases panel in Server view is the place to go to find the database creation dialog. Note that a configuration parameter, $cfg['ShowCreateDb'], controls the display of the Create new database dialog. By default, it is set to true, which shows the dialog.

No privileges

If you do not have the privilege to create a database, the panel displays a No privileges message under the Create new database label. This means that you must work with the databases already created for you, or ask the MySQL server's administrator to give you the necessary CREATE privilege.

Note

If you are the MySQL server's administrator, refer to Chapter 19.

First database creation is authorized

If phpMyAdmin detects that we have the right to create a database, the dialog appears as shown in the following screenshot:

First database creation is authorized

In the input field, a suggested database name appears if the $cfg['SuggestDBName'] parameter is set to TRUE, which is the default setting. The suggested database name is built according to the privileges we possess.

If we are restricted to the use of a prefix, the prefix might be suggested in the input field. (A popular choice for this prefix is the username, which might or might not be followed by an underscore character.) Note that, in this case, the prefix is followed by an ellipsis mark, added by phpMyAdmin. We should remove this ellipsis mark and complete the input field with an appropriate name.

First database creation is authorized

The Collation choice can be left unchanged for now. With this dialog, we could pick a default character set and collation for this database. This setting can be changed later (refer to Chapter 9 for more information on this).

We will assume here that we have the right to create a database named marc_book. We enter marc_book in the input field and click on Create. Once the database has been created, we will see the following screen:

First database creation is authorized

Notice the following:

  • The title of the main panel has changed to reflect the fact that we are now located in this database
  • A confirmation message regarding the creation is displayed
  • The navigation panel has been updated; we see marc_book
  • By default, the SQL query sent to the server by phpMyAdmin to create the database is displayed in color

Note

phpMyAdmin displays the query it generated, because $cfg['ShowSQL'] is set to TRUE. Looking at the generated queries can be a good way of learning SQL.

As the generated queries could be large and take much of the on-screen room, the $cfg['MaxCharactersInDisplayedSQL'] acts as a limit. Its default value of 1000 should be a good balance between seeing too few and seeing too many of the queries, especially when doing large imports.

It is important to examine the phpMyAdmin feedback to ascertain the validity of the operations we make through the interface. This way, we can detect errors like typos in the names, or creation of a table in the wrong database. phpMyAdmin retrieves error messages from the MySQL server and displays them on the interface.

主站蜘蛛池模板: 高碑店市| 德兴市| 三台县| 英山县| 五原县| 德兴市| 禄劝| 工布江达县| 手游| 班戈县| 南丹县| 霍林郭勒市| 邮箱| 利津县| 襄汾县| 青神县| 平度市| 永清县| 田林县| 开原市| 梨树县| 郎溪县| 申扎县| 深泽县| 贵阳市| 和顺县| 西昌市| 灌云县| 喜德县| 稻城县| 合江县| 桐梓县| 汝城县| 岑溪市| 衡阳县| 余江县| 廉江市| 绵阳市| 湖州市| 星座| 新宾|