美文网首页CentOS7中配置Mysql5.7
CentOS7-Mysql5.7配置(三)

CentOS7-Mysql5.7配置(三)

作者: Morphing0527 | 来源:发表于2019-05-25 15:36 被阅读0次

    2.10.3 Testing the Server

    After the data directory is initialized and you have started the server, perform some simple tests to make sure that it works satisfactorily. This section assumes that your current location is the MySQL installation directory and that it has a bin subdirectory containing the MySQL programs used here. If that is not true, adjust the command path names accordingly.

    Alternatively, add the bin directory to your PATH environment variable setting. That enables your shell (command interpreter) to find MySQL programs properly, so that you can run a program by typing only its name, not its path name. See Section 4.2.4, “Setting Environment Variables”.

    Use mysqladmin to verify that the server is running. The following commands provide simple tests to check whether the server is up and responding to connections:

    shell> bin/mysqladmin version
    shell> bin/mysqladmin variables
    

    If you cannot connect to the server, specify a -u root option to connect as root. If you have assigned a password for the root account already, you'll also need to specify -p on the command line and enter the password when prompted. For example:

    shell> bin/mysqladmin -u root -p version
    Enter password: (enter root password here)
    

    The output from mysqladmin version varies slightly depending on your platform and version of MySQL, but should be similar to that shown here:

    shell> bin/mysqladmin version
    mysqladmin  Ver 14.12 Distrib 5.7.27, for pc-linux-gnu on i686
    ...
    
    Server version          5.7.27
    Protocol version        10
    Connection              Localhost via UNIX socket
    UNIX socket             /var/lib/mysql/mysql.sock
    Uptime:                 14 days 5 hours 5 min 21 sec
    
    Threads: 1  Questions: 366  Slow queries: 0
    Opens: 0  Flush tables: 1  Open tables: 19
    Queries per second avg: 0.000
    

    To see what else you can do with mysqladmin, invoke it with the --help option.

    Verify that you can shut down the server (include a -p option if the root account has a password already):

    shell> bin/mysqladmin -u root shutdown
    

    Verify that you can start the server again. Do this by using mysqld_safe or by invoking mysqld directly. For example:

    shell> bin/mysqld_safe --user=mysql &
    

    If mysqld_safe fails, see Section 2.10.2.1, “Troubleshooting Problems Starting the MySQL Server”.

    Run some simple tests to verify that you can retrieve information from the server. The output should be similar to that shown here.

    Use mysqlshow to see what databases exist:

    shell> bin/mysqlshow
    +--------------------+
    |     Databases      |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    

    The list of installed databases may vary, but always includes at least mysql and information_schema.

    If you specify a database name, mysqlshow displays a list of the tables within the database:

    shell> bin/mysqlshow mysql
    Database: mysql
    +---------------------------+
    |          Tables           |
    +---------------------------+
    | columns_priv              |
    | db                        |
    | engine_cost               |
    | event                     |
    | func                      |
    | general_log               |
    | gtid_executed             |
    | help_category             |
    | help_keyword              |
    | help_relation             |
    | help_topic                |
    | innodb_index_stats        |
    | innodb_table_stats        |
    | ndb_binlog_index          |
    | plugin                    |
    | proc                      |
    | procs_priv                |
    | proxies_priv              |
    | server_cost               |
    | servers                   |
    | slave_master_info         |
    | slave_relay_log_info      |
    | slave_worker_info         |
    | slow_log                  |
    | tables_priv               |
    | time_zone                 |
    | time_zone_leap_second     |
    | time_zone_name            |
    | time_zone_transition      |
    | time_zone_transition_type |
    | user                      |
    +---------------------------+
    

    Use the mysql program to select information from a table in the mysql database:

    shell> bin/mysql -e "SELECT User, Host, plugin FROM mysql.user" mysql
    +------+-----------+-----------------------+
    | User | Host      | plugin                |
    +------+-----------+-----------------------+
    | root | localhost | mysql_native_password |
    +------+-----------+-----------------------+
    

    At this point, your server is running and you can access it. To tighten security if you have not yet assigned a password to the initial account, follow the instructions in Section 2.10.4, “Securing the Initial MySQL Account”.

    For more information about mysql, mysqladmin, and mysqlshow, see Section 4.5.1, “mysql — The MySQL Command-Line Client”, Section 4.5.2, “mysqladmin — Client for Administering a MySQL Server”, andSection 4.5.7, “mysqlshow — Display Database, Table, and Column Information”.

    相关文章

      网友评论

        本文标题:CentOS7-Mysql5.7配置(三)

        本文链接:https://www.haomeiwen.com/subject/cpqzzqtx.html