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.

Note

Data Management (DMS), including both the DMS web console and the DMS client, has been discontinued and is no longer maintained. If you previously used DMS to manage your Web Hosting MySQL database and experience issues such as login failures, tool errors, or connection failures to your database address (for example, *.my3w.com:3306), switch to the phpMyAdmin method described in this topic or use a third-party client such as Navicat for MySQL.

Procedure

  1. Obtain database information.
    1. Log on to the Cloud Web Hosting management page.
    2. Find the Cloud Web Hosting instance for which you want to obtain database information and click Manage in the Actions column.
    3. In the navigation pane on the left, click Database Information.
    4. On the Database Information page, obtain database information.
      Note If you forget your database password, reset it. For more information, see Reset the Cloud Web Hosting database password.
      In the Database Information section of the host management page, view information such as Database type (for example, Windows SQL Server 2008), Database name , Database address , and Database username . You can also perform operations such as resetting the password and managing the database.
  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.

FAQ

What do I do if my local database tool cannot connect to the Web Hosting MySQL database?

Troubleshoot the issue by checking the following:

  1. Verify your connection credentials. Make sure the database address, username, and password are entered correctly. You can find the connection information in the Web Hosting console.

  2. Check network connectivity. On your local computer, run ping and telnet commands to verify the connection to your database address. For example:

    ping your_database_address.my3w.com
    telnet your_database_address.my3w.com 3306

    If the connection times out or is refused, a network or firewall restriction may be blocking access to the database port.

  3. If the DMS client fails to connect, try the DMS web console as a fallback. If the issue persists, use the phpMyAdmin method described in this topic instead.

  4. Consider using Navicat for MySQL. Navicat for MySQL is a widely used third-party database client. Connect using your Web Hosting database address, port (3306), username, and password.