Overview
A direct access to phpMyAdmin allows you to manage, import, export and modify your databases as such.
Indeed, phpMyAdmin is a free software written in PHP designed to manage MySQL administration on the web. It supports a wide range of operations, most of which – database management, tables, columns, relationships, indexes, users, permissions, etc. – Most of them – database management, tables, columns, relationships, indexes, users, permissions, etc. – can be done through the user interface, while you still have the possibility to execute any SQL command directly.
In the following, we will limit ourselves to information related to the use for beginners.
Prerequisite
Access to https://mg.n0c.com/en/.
PHPMyAdmin
As soon as the database in SQL has been created (how), you can design it in PHPMyAdmin. You can also import it if it already exists on your machine.
Note
More experienced users can refer to the PHPMyAdmin documentation by clicking on this link: https://docs.phpmyadmin.net/en/latest/.
Access through N0C
- In the sidebar menu, select Databases -> PhpMyAdmin. This opens the phpMyAdmin software:
- The Navigation Panel (left side) is primarily used to choose a database or a table, or to come back to the phpMyAdmin Homepage.
- The purpose of the Main Panel, also called Central Page (right side), is to interact with the system.
How to Create a Table
- Click on the name of the database:
- Enter the Name and the Number of columns of the table.
- Click on the Go button.
- Enter following information for each field of the table :
- a. Name: defines the name of the table;
- b. Type: the type of data that will be recorded in the field. Most usual are INT (whole number), VARCHAR (short text), TEXT (long text) and DATE (date, month, year);
- c. Length/Values: maximum size of the field, useful for VARCHAR in particular, to limit the number of authorized characters;
- d. Index: activates the indexation of the field. This word means that the field will be adapted to queries. The PRIMARY index is used on fields of id type;
- e. A_I (AUTO_INCREMENT): allows the field to increment alone at each entry. It is often used for id type fields.
- Click on Save, so the table becomes visible in the left Navigation panel.
- Continue to create as many tables as necessary by repeating the previous steps.
How to Modify the Fields in a Table
Once created, a table is not fixed: you have the option to rename, delete and add fields, etc.
- After having chosen the table to modify in the left Navigation panel, click on the Structure tab.
- Click on relevant action, Change changes the field of table, while Drop removes a field.
- More gives access to icons allowing additional actions.
How to Insert Values in a Table
- Select a table in the left Navigation panel then click on the Insert tab.
- Fill in the Value fields.
How to Write a Query to be Executed in a Table
- Select a table in the left Navigation panel then click on the SQL tab.
- Write the query in the designated field.
- Then click on the Go button; the result of the query is then displayed.
How to Browse the Records in a Table
- Select a table in the left Navigation panel then click on the Browse tab.
- Entries are displayed.
How to Search Records in a Table
Before beginning, it is important to note that the operator LIKE means « exactly the same», while LIKE %…% means « includes ».
To search a value chosen in a table selected in the left Navigation panel.
- Click on the Search tab.
- Click on the Table Search tab.
- Using the Operator and Value fields, define search criteria.
- Click on the Go button.
- You can edit, copy, delete or export the entries.
- Other actions on the results of the query are possible.
To make a search by value on two different columns:
- Click on the Zoom search tab.
- Enter the requested information.
- Click on the Go button.
To search and replace a record:
- Click on the Find and replace tab.
- Enter the information in the Find field and the new data in Replace with field; then, specify the Column.
- Click on the Go button.
- Click on Replace to save the modified string.
Note
The % character (joker) replaces a string (it can be null).
How to Export a Table
- Select the desired table.
- Click on the Export tab.
- Define the format of the data you wish to export (SQL, CSV, PDF or other format).
- Click on the Go button.
How to Import Data from a Similar Table
Sometimes, it is more practical to use a file containing SQL queries in order to import many queries instead of writing each query individually.
- Select the desired table.
- Click on the Import tab.
- Define the import settings.
- Click on the Go button.
How to Perform Operations on a Table
More advanced users can modify tables with the Alter table functions.
You may need to:
- Rename table to: change the table name.
- Move table to (database.table): Move the table to another database.
- Copy table to (database.table): copy the table in the same database or another one (beware: in this case, it must have another name).
- Optimize table: speed up queries.
- Empty the table (TRUNCATE): empty all the data in the table. All records disappear and only the structure of the table stays (that is, the fields). Beware: this operation cannot be undone.
- Delete the table (DROP): removes one or more tables (structure and data). You must have the DROP privilege for each table. Once again, be careful before deleting a table, as nothing can be recovered afterwards, unless a save has been done previously with the export tool.
- Select the desired table.
- Click on the Operations tab.
How to Manage the Triggers on a Table
- Select the desired table.
- Click on the Triggers tab.
- Click on Add trigger.
- Define the procedure for each trigger and click on the Go button.
How to Empty a Saturated Table
It often happens that a user saturates a table while making a blog. It is then mandatory to empty the table.
Note
Before doing so, check the content of the table to avoid losing important elements of your website, such as articles.
- Select the table causing problems.
- Check Check all.
- Click on Delete to empty the table.
How to Export a Database
The PHPMyAdmin function has two purposes:
- exporting databases on the Internet;
- make backup copies of databases in several export file formats (dump).
If the SQL format is chosen, the file that you will obtain upon exporting with phpMyAdmin specifies to MySQL how to recreate your databases with SQL queries.
Note
It is strongly recommended to make a backup of your database before exporting anything in PHPmyAdmin.
How to Export all Your Databases
- Go to the Homepage.
- Click on the Export tab.
- Define the Export method by clicking on the Quick – display only the minimal options radio button.
- Define the export file Format (SQL, CSV, PDF or any other format).
- Click on Go button.
How to Export Selected Databases
- Go to the Homepage.
- Click on the Export tab.
- Define the Export method by clicking on the Custom – display all possible options radio button.
- Define the export file Format (SQL, CSV, PDF or any other format).
- Select your Databases to export.
- The options depend on the chosen format (SQL only is used for our explanations in this article). In Output, choose Rename exported databases/tables/columns if needed.
- Enter relevant information.
- Click the Save & close button.
- Continue to fill in the Output options (you can choose either Save output to a file or View output as text).
- Define the Format-specific options.
- If you choose to export the structure only, click on Structure.
- Define the Object creation options.
- Click on the Go button.
- If you choose to export the data only, click Data.
- Define Data creation options and click on the Go button.
- If you choose to export structure and data, click Structure and data.
- Define Object creation options and Data creation options, and click Go.
How to Import a Database With phpMyAdmin
It is important to know good practices for importing databases.
You must have an empty database in your N0C account in order to import one. In addition, you must ensure that if your file is compressed, its name ends with .[format].[compression].
Example:. sql.zip. If the .sql you attempt to import is too large for phpMyAdmin, you have to import it with SSH (in this case, please see section How to import a database in command line).
- Refer to the section Create an SQL database and follow the creation steps.
- Click on the name of the database that will receive import information. The page will refresh to display the related information.
- Click on the Import tab.
- Click Choose file. Your browser will then allow you to select the database file on your computer.
- Define the Character set of the file.
- Check Partial import options:
- allowing the interruption of an import in case the script detects it is close to the PHP timeout limit might be a good way to import large files; however it can break transactions;
- the field Skip this number of queries (for SQL) starting from the first one allows you to ignore some queries at the beginning.
- Check Enable foreign key checks under Other options in order to insert tables that have foreign keys.
- Choose the Format (SQL by default).
- Choose Format specific options. They allow you to choose a compatibility mode. This is very useful in particular to import various types of SQL files from many databases (ANSI, ORACLE, etc.).
- Click on the Go button.
As soon as the file import is finished, the data and the structure it contains will be available for use in the database.
How to Import a Database in Command Line
Importing a database via SSH can be done in Windows with puTTY software. It can also be done directly with the terminal in some environments. We will cover the use of Windows in this article.
For our example, let’s suppose the user having the username « fbkfdayw » desires to import a database called « atomes.sql » in an empty database called « BD_Atomes ».
Note
This procedure is for advanced users. Always save your work beforehand.
Recover your Password
The first step is to recover your username and your password from your hosting.
Prepare hosting
- Refer to the section Create an SQL database and follow the steps to create your empty « BD_Atomes » database where the import will be done.
- Create the exportat file (dump) on your machine — « atomes.sql » in our example (how).
- Send the export file to the N0C server. There are 2 possibilities, the first one is recommended:
- connect to your N0C hosting in FTP (how);
- connect to N0C and perform an Upload on File Manager (how).
Connection in SSH
You are now ready to remotely connect from your machine.
- Load PuTTY from its official website. Click on the installation program (here, putty-64bit-0.74-installer.msi).
- Then, run PuTTY. Make sure that the Connection Type is set to SSH in the PuTTY Configuration window.
- Enter your server IP address or Host Name (for example, node2-ca.n0c.com). If the Host Name is not convenient, enter localhost instead.
- Specify the port. This varies depending on the hosting type you have: unless otherwise specified, use 5022 for the Port fields.
- To save the information kept in memory – so it is not necessary to redo this at each connection – give a name to the session in the field named Saved Sessions and click on the Save button.
- Launch the SSH session by clicking on the Open button. On the first time, PuTTY should ask for a confirmation.
- As the server displays login as:, identify yourself by entering your username and press the Enter key on your keyboard.
- Enter your password (since you have copied it at step 3 when you recovered your password, you can right click your mouse).
Import in Command Line
You are now ready to import your dump file in the empty database.
- Launch the import command:
mysql -u user -ppass database < file_dump
Where :
- user: the user you wish to connect with.
- pass: the password of this user.
- database: the name of the database where data will be imported.
- file_dump: name of the dump file containing SQL instructions to import.
In our example, we will write :
mysql -u fbkfdayw -ppass fbkfdayw_BD_Atomes < atomes.sql
- You can then access phpMyAdmin and confirm that your database has been imported.
Some Useful Putty Commands
Command | Definition |
ls | Used to list the content of the folder you are in. |
cd | Used to browse the folders of your machine. For exemple, if your are at the root of the machine and you desire to go to public_html/xyz.ca, you have to type cd public_html/xyz.ca. If you just type cd, this brings you to your user or root depending on what your are connected with. |
cd .. | Used to go to one folder higher. If, for example, you are in / public_html/xyz.ca and you want to go in /public_html, type « cd.. ». |
exit | Used to disconnect. |
Settings
The Settings tab allows you to configure PhpMyAdmin as you desire. Preferences are saved in current sessions only.
A permanent storage requires the installation of phpMyAdmin configuration storage.
You can customize the information displayed on various pages:
Tab | Description |
Manage your settings | Allows you to change the default selections of Import and Export tabs. |
Two-factor authentification | Adds a second element to authentification besides a password. By default, authentification using only a password is selected. |
Features | Allows you to personalize some functions: text fields, browser’s title bar text, disable some of the warnings shown by phpMyAdmin and console for SQL queries. |
SQL queries | Allows you to configure SQL query parameters and to customize links shown in SQL Query boxes. |
Navigation panel | Customize the appearance of the navigation panel (left panel). |
Main panel | Customize the startup page (right panel). |
Export | Customize the default export options associated to various formats (SQL, CodeGen, CSV, LaTex, Microsoft Office, OpenDocument and Texte Texy. |
Import | Used to customize the values usually used for import and the default options associated with various formats (SQL, CSV and OpenDocument). |
Server Variables and Parameters
The Variables tab contains all MySQL variables and their values.
The Edit action allows you to change the value of any variable. Take note that you cannot necessarily change the values of all variables, this being permitted only for the root user on the server.
Character Sets and Collations
The Charsets tab gives access to the character sets and list of each collation supported by the MySQL server.
Storage Engines
The Engines tab opens a page wth all storage engines that are supported by the MySQL server.
InnoDB is selected by default. Users can refer to the documentation by clicking here to get more information about storage engines.
Plugins
The Plugins tab opens a page showing all installed MySQL plugins, with relevant information such as description and version.