perror Command in Linux



The perror command in Linux explains the error codes in MariaDB or MySQL environment. It is used to display human-readable messages corresponding to error codes. It is often used in debugging and development to understand the meaning of error codes.

Table of Contents

Here is a comprehensive guide to the options available with the perror command −

Installation of perror Command

The perror command is a part of MariaDB. To install perror on Ubuntu, Kali Linux, Raspberry Pi OS, Debian, and other Debian-based distributions, use the command given below −

sudo apt install mariadb-client

To install it on Fedora, run the command given below −

sudo dnf install mariadb-client

To install it on Arch Linux, execute −

sudo pacman -S mariadb

To install perror on CentOS or RHEL, use the following command −

sudo yum install mariadb-client

Syntax of perror Command

The syntax of the perror command in Linux is as follows −

perror [options] [errorcode...]

In the above syntax, the [options] field is used to specify the optional flags to modify the behavior of the command. The [errorcode...] is used to mention one or more error codes to interpret. These can be either system error codes or MariaDB/MySQL-specific error codes.

perror Command Options

The options of the perror command are listed below −

Flags Option Description
-I, -? --help, --info Display a help message and exit
-s --silent Display only the error message
-v --verbose Display the error code and message (This is the default behavior)
-V --version Display version information and exit

Examples of perror Command in Linux

This section demonstrates the usage of the perror command in Linux with examples −

Checking System Error Codes

To decode the system error codes, use the perror command with the system error code numbers −

perror 2 13
perror Command in Linux1

The above command displays the description of the error type, which is OS error code and its description.

Here are some common system error codes −

Error Codes Description
1 Operation not permitted.
22 Invalid argument.
17 File already exists.
28 No space left on device.
39 Directory not empty.
64 Machine is not on the network.
71 Protocol error.
111 Connection refused.
122 Disk quota exceeded.
126 Command not executable.
127 Command not found.
139 Segmentation fault.

Checking MariaDB/MySQL-Specific Error Codes

To get an explanation of MariaDB or MySQL-specific error codes, use the perror command with the code −

perror 1049
perror Command in Linux2

Other common MariaDB or MySQL-specific error codes are listed below −

Error Codes Description
1045 Access Denied: Incorrect username or password.
1049 Unknown Database: The specified database does not exist.
1050 Table already exists: Attempt to create a table that already exists.
1064 Syntax Error: A syntax error in the SQL statement.
1062 Duplicate entry: Attempt to insert a duplicate value into a unique key.
1146 Table does not exist: The specified table does not exist.
1213 Deadlock found: A deadlock error occurs when two or more transactions block each other.
1205 Lock wait timeout exceeded: A transaction waited too long for a lock.
1061 Duplicate key name: Attempt to create an index with a duplicate name.
1030 Got error from storage engine: An error occurred during data manipulation with the storage engine.
1063 Unknown column: Reference to a column that does not exist in the table.
1136 Column count does not match: The number of columns in the query does not match the table's structure.
1156 Column length exceeds limit: A column exceeds the maximum allowed length.
1040 Too many connections: The server has reached its maximum allowed number of simultaneous connections.
1206 Too long key prefix: The key length is too long for the specified table engine.
1364 Field does not have a default value: When inserting into a table, a field that does not allow NULL values is not given a value.
1451 Cannot delete or update a parent row: Occurs due to foreign key constraints when trying to delete a record that is referenced in another table.
1452 Cannot add or update a child row: Occurs due to foreign key constraints when trying to add or update a row that violates foreign key rules.

Using Silent Mode

To suppress additional information from the output, use the -s or --silent option −

perror -s 17
perror Command in Linux3

Displaying Help

To display help about the perror command, use any option from -h, -help, --help, or -?

perror -?

Conclusion

The perror command in Linux is a useful tool for interpreting error codes in MariaDB and MySQL environments. It helps display human-readable messages for system and database-specific error codes, helping in debugging and development. By using various options, such as silent mode or verbose mode, the output can be tailored to specific needs.

Advertisements