Connect to MySQL by using phpMyAdmin

更新时间:
复制 MD 格式

phpMyAdmin is a web-based management tool for MySQL databases. It allows you to create and delete databases, create and modify tables, and run SQL scripts. This topic shows you how to use phpMyAdmin to connect to a MySQL database on a Linux-based Web Hosting instance.

Prerequisites

Background

The database connection configuration file name varies by phpMyAdmin version. Ensure you use the file name that matches your version.

phpMyAdmin versions have specific compatibility requirements for PHP versions. For more information, see the official phpMyAdmin website.

Note

Select a compatible PHP version for your Web Hosting instance based on your phpMyAdmin version. For more information, see Change the PHP version.

Procedure

  1. Obtain the database information.
    1. Log on to the Web Hosting management page.
    2. Find the Web Hosting instance and click Manage in the Actions column.
    3. In the navigation pane, click Database Information.
    4. On the Database Information page, obtain the database information.
      Note If you forget your database password, you can reset it. For more information, see Reset the database password for a Web Hosting instance.
      数据库
  2. Configure the database connection for phpMyAdmin.

    1. Decompress the phpMyAdmin-5.1.1-all-languages installation package on your local host.

    2. Open the phpMyAdmin-5.1.1-all-languages folder, locate the database connection configuration file config.sample.inc.php, and modify the database connection information in the file.

      An example from config.sample.inc.php:

      /* Server your.host.example.com (config:****) */
      $i++;
      /* Authentication type */
      $cfg['Servers'][$i]['auth_type'] = 'cookie';
      /* Server parameters */
      $cfg['Servers'][$i]['host'] = 'your_database_address';
      $cfg['Servers'][$i]['compress'] = false;
      $cfg['Servers'][$i]['AllowNoPassword'] = false;
      /* User used to manipulate with storage */
      $cfg['Servers'][$i]['controlhost'] = 'your_database_address';
      $cfg['Servers'][$i]['controlport'] = '3306';
      $cfg['Servers'][$i]['controluser'] = 'your_database_username';
      $cfg['Servers'][$i]['controlpass'] = 'your_database_password';

      Replace the placeholders in the code with your database information.

    3. Save the modified database connection configuration file config.sample.inc.php, and rename the file to config.inc.php.

    4. On your local host, recompress the files in the phpMyAdmin-5.1.1-all-languages installation package, and rename the compressed package to phpMyAdmin.

      Linux-based Web Hosting instances can only decompress .zip and .tar files. We recommend compressing the installation files into a .zip package.

      Note

      Make sure that the phpMyAdmin-5.1.1-all-languages installation package is a single-level directory, which means the directory directly contains the component files. If the phpMyAdmin-5.1.1-all-languages installation package contains an extra directory layer, compress the files from that directory into a .zip archive, rename the archive to phpMyAdmin, and save it on your local computer for installation.

  3. Use an FTP client to upload the phpMyAdmin archive to the website root directory of your Linux Web Hosting instance, /htdocs.

  4. On the File Manager page of the Web Hosting console, unzip the phpMyAdmin compressed package.

    For more information, see Compress and decompress files.

  5. In the address bar of the browser on your local host, enter your domain name, and press the Enter key.

    Note

    If your domain name is not ready, you can use the temporary domain name for testing.

  6. On the phpMyAdmin page, enter your database username and password in the Login section, and then click Go.

Results

After you log on to phpMyAdmin, you can manage the MySQL database for your Web Hosting instance.

The phpMyAdmin homepage displays server connection information, such as Server version, Protocol version, and Character set. The navigation pane lists your databases.