Error
Error Code:
71
MySQL Error 71: Option Requires Argument
Description
MySQL Error 71 indicates that a command-line option was provided without its necessary argument or value. This typically occurs when executing MySQL client utilities or scripts that require specific parameters for options like `--user`, `--host`, or `--port`, but the value is missing or improperly formatted.
Error Message
%s: option '--%s' requires an argument.
Known Causes
3 known causesMissing Argument Value
The most common cause is simply forgetting to specify a value immediately after an option that expects one, such as `--host` without `localhost` or `--user` without `root`.
Incorrect Syntax or Spacing
The option and its argument might be separated by incorrect spacing, or an `=` sign might be missing when required, causing the system to interpret the option as having no argument.
Misinterpreting Option Type
Assuming an option is a simple flag (a boolean switch) when it actually expects a specific value or parameter to function correctly.
Solutions
3 solutions available1. Correctly Specify Option Arguments easy
Ensure that all MySQL options requiring an argument are provided with one.
1
Review the command or configuration file where the error occurred. Identify the option mentioned in the error message (e.g., '--port' or '--socket').
2
Append the required argument to the option. For example, if the error is about '--port', you should specify it like '--port 3306'. If it's about '--socket', it would be '--socket /var/run/mysqld/mysqld.sock'.
--port 3306
--socket /var/run/mysqld/mysqld.sock
3
Re-run the command or restart the MySQL service with the corrected configuration.
2. Verify MySQL Client or Server Configuration medium
Check the command-line arguments or configuration files for missing option values.
1
If the error occurs when starting the MySQL server (mysqld), examine the command-line arguments used to launch it. This might be in a systemd service file, an init script, or a manual startup command.
Example systemd service file snippet:
[Service]
ExecStart=/usr/sbin/mysqld --user=mysql --port=3306 --datadir=/var/lib/mysql
2
If the error occurs when using a MySQL client (like 'mysql' command-line client), check the arguments you are passing to it. Ensure options like '--host', '--user', '--password' (though password should ideally be handled securely), or '--port' have their corresponding values.
mysql --host=localhost --user=myuser --port=3306
3
If you are using a configuration file (e.g., my.cnf, my.ini), locate the relevant section (e.g., [mysqld], [client]) and verify that options requiring values have them correctly specified on the following line or immediately after an equals sign.
[mysqld]
port = 3306
socket = /var/run/mysqld/mysqld.sock
4
Correct any missing arguments and restart the MySQL service or re-run the client command.
3. Update or Reinstall MySQL Client/Server advanced
A corrupted or outdated installation might cause incorrect option parsing.
1
Back up your MySQL data and configuration files. This is a critical step before any reinstallation.
mysqldump --all-databases > all_databases_backup.sql
2
Uninstall the current MySQL server and client packages.
sudo apt-get remove --purge mysql-server mysql-client mysql-common
# Or for Red Hat/CentOS:
sudo yum remove mysql-server mysql-client
# Or for other systems, consult your package manager.
3
Clean up any remaining configuration files or directories if necessary (be cautious here).
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
4
Install the latest stable version of MySQL from official repositories or the MySQL website.
sudo apt-get update
sudo apt-get install mysql-server mysql-client
# Or for other systems, consult your package manager or MySQL documentation.
5
Restore your data from the backup and reconfigure MySQL as needed.
mysql -u root -p < all_databases_backup.sql