4.2.3.1. Using Options on the Command Line

本文介绍了MySQL命令行程序中各种选项的使用规则,包括短选项和长选项的形式、选项值的指定方式、特殊选项如密码的处理方法以及如何正确引用包含空格的选项值等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Program options specified on the command line follow these rules:

  • Options are given after the command name.

  • An option argument begins with one dash or two dashes, depending on whether it is a short form or long form of the option name. Many options have both short and long forms. For example, -? and --help are the short and long forms of the option that instructs a MySQL program to display its help message.

  • Option names are case sensitive. -v and -V are both legal and have different meanings. (They are the corresponding short forms of the --verbose and --version options.)

  • Some options take a value following the option name. For example, -h localhost or --host=localhost indicate the MySQL server host to a client program. The option value tells the program the name of the host where the MySQL server is running.

  • For a long option that takes a value, separate the option name and the value by an = sign. For a short option that takes a value, the option value can immediately follow the option letter, or there can be a space between: -hlocalhost and -h localhost are equivalent. An exception to this rule is the option for specifying your MySQL password. This option can be given in long form as --password=pass_val or as --password. In the latter case (with no password value given), the program prompts you for the password. The password option also may be given in short form as -ppass_val or as -p. However, for the short form, if the password value is given, it must follow the option letter with no intervening space. The reason for this is that if a space follows the option letter, the program has no way to tell whether a following argument is supposed to be the password value or some other kind of argument. Consequently, the following two commands have two completely different meanings:

    shell> mysql -ptest
    shell> mysql -p test
    

    The first command instructs mysql to use a password value of test, but specifies no default database. The second instructs mysql to prompt for the password value and to use test as the default database.

  • Within option names, dash (-) and underscore (_) may be used interchangeably. For example, --skip-grant-tables and --skip_grant_tables are equivalent. (However, the leading dashes cannot be given as underscores.)

  • For options that take a numeric value, the value can be given with a suffix of KM, or G (either uppercase or lowercase) to indicate a multiplier of 1024, 10242 or 10243. For example, the following command tells mysqladminto ping the server 1024 times, sleeping 10 seconds between each ping:

    mysql> mysqladmin --count=1K --sleep=10 ping
    

Option values that contain spaces must be quoted when given on the command line. For example, the --execute(or -e) option can be used with mysql to pass SQL statements to the server. When this option is used, mysqlexecutes the statements in the option value and exits. The statements must be enclosed by quotation marks. For example, you can use the following command to obtain a list of user accounts:

mysql> mysql -u root -p --execute="SELECT User, Host FROM mysql.user"
Enter password: ******
+------+-----------+
| User | Host      |
+------+-----------+
|      | gigan     |
| root | gigan     |
|      | localhost |
| jon  | localhost |
| root | localhost |
+------+-----------+
shell>

Note that the long form (--execute) is followed by an equal sign (=).

If you wish to use quoted values within a statement, you will either need to escape the inner quotation marks, or use a different type of quotation marks within the statement from those used to quote the statement itself. The capabilities of your command processor dictate your choices for whether you can use single or double quotation marks and the syntax for escaping quote characters. For example, if your command processor supports quoting with single or double quotation marks, you can use double quotation marks around the statement, and single quotation marks for any quoted values within the statement.

************************************************************************ * Build and Install HDF5 Applications with CMake * ************************************************************************ Notes: This short instruction is written for users who want to quickly build HDF5 applications using the CMake tools. Users can adapt these instructions for their own applications. For more information, see the "Minimum C Project Files for CMake" section. More information about using CMake can be found at the KitWare site, www.cmake.org. CMake uses the command line; however, the visual CMake tool is available for the configuration step. The steps are similar for all of the operating systems supported by CMake. NOTES: 1. Using CMake for building and using HDF5 is under active development. While we have attempted to provide error-free files, please understand that development with CMake has not been extensively tested outside of HDF. The CMake specific files may change before the next release. 2. CMake for HDF5 development should be usable on any system where CMake is supported. Please send us any comments on how CMake support can be improved on any system. 3. See the appendix at the bottom of this file for an example of using a ctest script for building and testing. See INSTALL_CMake.txt for more information. 4. See https://cmake.org/cmake/help/latest/command/find_package.html for more information on the CMake "Config Mode Search Procedure". ======================================================================== I. Preconditions ======================================================================== 1. We suggest you obtain the latest CMake for your platform from the Kitware web site. The HDF5 1.12.x product requires a minimum CMake version of 3.12. If you are using VS2019, the minimum version is 3.15. For VS2022, the minimum version is 3.21. 2. You have installed the HDF5 library built with CMake, by executing the HDF Install Utility (the *.msi file in the binary package for Windows or the *.sh on Linux). You can obtain pre-built binaries from The HDF Group&#39;s website at www.hdfgroup.org. 3. Set the HDF5_ROOT CMake variable, -DHDF5_ROOT=<install_path> or environment variable, set(ENV{HDF5_ROOT} "<install_path>") to the installed location of HDF5. On Windows: HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/1.12.x/ On unix: HDF5_ROOT=<install root folder>/HDF_Group/HDF5/1.12.x/ If you are using shared libraries, you may need to add to the path environment variable. Set the path environment variable to the installed location of the library files for HDF5. On Windows (*.dll): PATH=%PATH%;C:/Program Files/HDF_Group/HDF5/1.12.x/bin On unix (*.so): LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF5/1.12.x/lib If you are using filter plugin libraries, you will need to set the HDF5_PLUGIN_PATH environment variable. On Windows: HDF5_PLUGIN_PATH=C:/Program Files/HDF_Group/HDF5/1.12.x/lib/plugin On unix: HDF5_PLUGIN_PATH=<install root folder>/HDF_Group/HDF5/1.12.x/lib/plugin (Note there are no quote characters used on Windows and all platforms use forward slashes) 4. Created separate source and build directories. (CMake commands are executed in the build directory) 5. Created a CMakeLists.txt file(s) for your source. See Section III below. ======================================================================== II. Building HDF5 Applications with CMake ======================================================================== Go through these steps to build HDF5 applications with CMake. (The application must support building with CMake.) 1. Run CMake 2. Configure the cache settings 3. Build HDF5 Applications 4. Test HDF5 Applications These steps are described in more detail below. 1. Run CMake The visual CMake executable is named "cmake-gui.exe" on Windows and should be available in your Start menu. For Linux, UNIX, and Mac users the executable is named "cmake-gui" and can be found where CMake was installed. Specify the source and build directories. Make the build and source directories different. For example on Windows, if the source is at c:\MyHDFstuff\hdf5, then use c:\MyHDFstuff\hdf5\build or c:\MyHDFstuff\build\hdf5 for the build directory. PREFERRED: Users can perform the configuration step without using the visual cmake-gui program. The following is an example command line configuration step executed within the build directory: cmake -G "<generator>" [-D<options>] <sourcepath> Where <generator> is * MinGW Makefiles * NMake Makefiles * Unix Makefiles * Visual Studio 14 2015 * Visual Studio 14 2015 Win64 * Visual Studio 15 2017 * Visual Studio 15 2017 Win64 * Visual Studio 16 2019 * ... in addition VS2019 will need to set the "-A" option, * ... [Win32, x64, ARM, ARM64] * Visual Studio 17 2022 * ... in addition VS2022 will need to set the "-A" option, * ... [Win32, x64, ARM, ARM64] <options> is: * BUILD_TESTING:BOOL=ON * BUILD_SHARED_LIBS:BOOL=[ON | OFF] 2. Configure the cache settings 2.1 Visual CMake users, click the Configure button. If this is the first time you are running cmake-gui in this directory, you will be prompted for the generator you wish to use (for example on Windows, Visual Studio 14 2015 Win64). CMake will read in the CMakeLists.txt files from the source directory and display options for the HDF5 project. After the first configure you can adjust the cache settings and/or specify locations of other programs. Any conflicts or new values will be highlighted by the configure process in red. Once you are happy with all the settings and there are no more values in red, click the Generate button to produce the appropriate build files. On Windows, if you are using a Visual Studio generator, the solution and project files will be created in the build folder. On linux, if you are using the Unix Makefiles generator, the Makefiles will be created in the build folder. 2.2 Alternative command line example on Windows in c:\MyHDFstuff\hdf5\build directory: cmake -G "Visual Studio 14 2015 Win64" -DBUILD_TESTING:BOOL=ON .. 3. Build HDF5 Applications On Windows, you can build HDF5 applications using either the Visual Studio Environment or the command line. The command line is normally used on linux, Unix, and Mac. To build from the command line, navigate to your build directory and execute the following: cmake --build . --config {Debug | Release} NOTE: "--config {Debug | Release}" may be optional on your platform. We recommend choosing either Debug or Release on Windows. If you are using the pre-built binaries from HDF, use Release. 3.1 If you wish to use the Visual Studio environment, open the solution file in your build directory. Be sure to select either Debug or Release and build the solution. 4. Test HDF5 Applications To test the build, navigate to your build directory and execute: ctest . -C {Debug | Release} NOTE: "-C {Debug | Release}" may be optional on your platform. We recommend choosing either Debug or Release to match the build step on Windows. 5. The files that support building with CMake are all of the files in the config/cmake folder, the CMakeLists.txt files in each source folder, and CTestConfig.cmake. CTestConfig.cmake is specific to the internal testing performed by The HDF Group. It should be altered for the user&#39;s installation and needs. The cacheinit.cmake file settings are used by The HDF Group for daily testing. It should be altered/ignored for the user&#39;s installation and needs. ======================================================================== III. Minimum C Project Files for CMake ======================================================================== Given the preconditions in section I, create a CMakeLists.txt file at the source root. Include the following text in the file: ########################################################## cmake_minimum_required (VERSION 3.12) project (HDF5MyApp C CXX) set (LIB_TYPE STATIC) # or SHARED string(TOLOWER ${LIB_TYPE} SEARCH_TYPE) find_package (HDF5 NAMES hdf5 COMPONENTS C ${SEARCH_TYPE}) # find_package (HDF5) # Find non-cmake built HDF5 set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIR}") set (LINK_LIBS ${LINK_LIBS} ${HDF5_C_${LIB_TYPE}_LIBRARY}) set (example hdf_example) add_executable (${example} ${PROJECT_SOURCE_DIR}/${example}.c) TARGET_C_PROPERTIES (${example} PRIVATE ${LIB_TYPE}) target_link_libraries (${example} ${LINK_LIBS}) enable_testing () include (CTest) add_test (NAME test_example COMMAND ${example}) ########################################################## ======================================================================== IV. APPENDIX ======================================================================== Below is an example of a ctest script that can be used to build the examples. Adjust the values as necessary. Note that the defaults can be entered on the command line and the build folder is created as a sub-folder. Windows should adjust the forward slash to double backslashes, except for the HDF_DIR environment variable. NOTE: this file is available at the HDF web site: https://portal.hdfgroup.org/display/support/Building+HDF5+with+CMake HDF5_Examples.cmake HDF5_Examples_options.cmake Also available at the HDF web site is a CMake application framework template. You can quickly add files to the framework and execute the script to compile your application with an installed HDF5 binary. ======================================================================== For further assistance, send email to help@hdfgroup.org ========================================================================
06-27
1. Compilation 1.1 Windows A workspace for MS Visual Studio is provided with the name "hpm_vsXXXX.sln" in the directory "build\x86_windows". It contains the encoder and decoder projects. 1.2 Unix/Linux Makefiles are provided in the directory "build\x86_linux". &#39;make&#39; command will create the obj files and generate the executable file in the &#39;bin&#39; directory. 1.3 CMake for HPM Example for Windows: mkdir build_cmake cd build_cmake cmake .. -G open "HPM.sln" in build_cmake directory to generate the executable files to "build_cmake/app/Debug" or "build_cmake/app/Release" directory. Example for Linux: mkdir build_cmake cd build_cmake cmake .. make -j &#39;make&#39; command will generate the executable file to the &#39;build_cmake/app&#39; directory. ******************************************************************* 2. Command line parameters 2.1 Encoder encoder_app [--config file] [-paramShort ParameterValue] [--paramLong ParameterValue] --config file All Parameters are initially taken from the &#39;file&#39;, typically: "encode_RA.cfg". -paramShort ParameterValue --paramLong ParameterValue If -paramShort or --paramLong parameters are present, then the ParameterValue will override the default settings in the configuration file. 2.2 Decoder decoder_app [-paramShort ParameterValue] [--paramLong ParameterValue] All decoding parameters are set by the command lines. ******************************************************************* 3. Examples of command line For SDR, using cfg\encode_RA.cfg For PG, using cfg\HDR\encode_RA_PG.cfg For HLG, using cfg\HDR\encode_RA_HLG.cfg 3.1 Random Access build\x86_windows\x64\Release\encoder_app --config cfg\encode_RA.cfg -i City_1280x720_60.yuv -w 1280 -h 720 -z 60 -p 64 -f 9 -d 8 -q 45 -o City_RA.bin -r City_RA_rec.yuv build\x86_windows\x64\Release\decoder_app -s -i City_RA.bin -o City_RA_dec.yuv 3.2 All Intra build\x86_windows\x64\Release\encoder_app --config cfg\encode_AI.cfg -i City_1280x720_60.yuv -w 1280 -h 720 -z 60 -f 9 -d 8 -q 45 -o City_AI.bin -r City_AI_rec.yuv build\x86_windows\x64\Release\decoder_app -s -i City_AI.bin -o City_AI_dec.yuv 3.3 Low Delay build\x86_windows\x64\Release\encoder_app --config cfg\encode_LD.cfg -i City_1280x720_60.yuv -w 1280 -h 720 -z 60 -f 9 -d 8 -q 45 -o City_LD.bin -r City_LD_rec.yuv build\x86_windows\x64\Release\decoder_app -s -i City_LD.bin -o City_LD_dec.yuv ******************************************************************* 4. Configuration files The default configuration files are provided in the directory "cfg". These contain explanatory comments for each parameter. If the parameter name is undefined, the program will be terminated with an error message. *******************************************************************
最新发布
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值