龙空技术网

在工作中常用到的mysql命令总结(一)

启发君来了 5

前言:

现时小伙伴们对“mysql 命令行远程登录”可能比较注意,小伙伴们都需要了解一些“mysql 命令行远程登录”的相关文章。那么小编同时在网上搜集了一些关于“mysql 命令行远程登录””的相关内容,希望同学们能喜欢,朋友们快快来了解一下吧!

1、查看表的基本结构命令:

>show create table INNODB_TRX;

| INNODB_TRX | CREATE TEMPORARY TABLE `INNODB_TRX` (

`trx_id` bigint unsigned NOT NULL DEFAULT '0',

`trx_state` varchar(13) NOT NULL DEFAULT '',

`trx_started` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',

`trx_requested_lock_id` varchar(105) DEFAULT NULL,

`trx_wait_started` datetime DEFAULT NULL,

`trx_weight` bigint unsigned NOT NULL DEFAULT '0',

`trx_mysql_thread_id` bigint unsigned NOT NULL DEFAULT '0',

`trx_query` varchar(1024) DEFAULT NULL,

`trx_operation_state` varchar(64) DEFAULT NULL,

`trx_tables_in_use` bigint unsigned NOT NULL DEFAULT '0',

`trx_tables_locked` bigint unsigned NOT NULL DEFAULT '0',

`trx_lock_structs` bigint unsigned NOT NULL DEFAULT '0',

`trx_lock_memory_bytes` bigint unsigned NOT NULL DEFAULT '0',

`trx_rows_locked` bigint unsigned NOT NULL DEFAULT '0',

`trx_rows_modified` bigint unsigned NOT NULL DEFAULT '0',

`trx_concurrency_tickets` bigint unsigned NOT NULL DEFAULT '0',

`trx_isolation_level` varchar(16) NOT NULL DEFAULT '',

`trx_unique_checks` int NOT NULL DEFAULT '0',

`trx_foreign_key_checks` int NOT NULL DEFAULT '0',

`trx_last_foreign_key_error` varchar(256) DEFAULT NULL,

`trx_adaptive_hash_latched` int NOT NULL DEFAULT '0',

`trx_adaptive_hash_timeout` bigint unsigned NOT NULL DEFAULT '0',

`trx_is_read_only` int NOT NULL DEFAULT '0',

`trx_autocommit_non_locking` int NOT NULL DEFAULT '0',

`trx_schedule_weight` bigint unsigned DEFAULT NULL

) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 |

2、查看mysql数据库有没有锁的命令:

select trx_id,TRX_STATE,TRX_STARTED,TRX_REQUESTED_LOCK_ID,TRX_MYSQL_THREAD_ID,TRX_QUERY,TRX_TABLES_IN_USE,TRX_TABLES_LOCKED from information_schema.INNODB_TRX;

3、创建表的命令:

create table test002(id int);

insert into test002 values (200);

4、使用命令行远程登陆数据库

mysql -h 10.1.1.56 -P24562 -u testusr -p'testusr'

5、测试网络是否通

telnet 10.1.1.56 24562

6、创建数据库命令并且如何为用户进行授权和设置用户的密码命令参考:

create database testdb01;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'localhost' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.%.%.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.1.%.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.19.%.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.19.51.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.4.%.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.19.58.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.19.99.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON testdb01.* TO 'testusr1o'@'10.17.%.%' IDENTIFIED BY 'testdb01_testusr1o#_8899' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'localhost' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.%.%.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.1.%.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.19.%.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.4.%.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.19.51.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.19.58.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.1.123.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.19.99.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

GRANT select,insert,delete,update,execute ON testdb01.* TO 'testusr1c'@'10.17.%.%' IDENTIFIED BY 'testdb01_testusr1c#_6677' WITH GRANT OPTION;

flush privileges;

更多mysql数据库知识敬请期待。

标签: #mysql 命令行远程登录