mysql 连接
2017-03-25 01:27
190 查看
##mysql 连接:
unix系统上,mysql的登陆方式有两种,分别是socket和tcp/ip方式登陆。mysql登陆的时候,指定参数-h,会使用tcp/ip的方式连接,如果没有指定端口的话,默认是使用3306端口
当mysql登陆时,同时指定-h和-S,mysql会默认使用tcp/ip的方式连接。默认情况下访问3306端口。
在生产环境使用 :mysql -uroot -p -h<本机ip> 可能会失败
hosts 配置文件是用来把主机名字映射到IP地址的方法
vim /etc/hosts –hosts文件 有没有 关于 localhost 127.0.0.1
mysql>select * from mysql.user where User=’root’\G
– 可以查看到 有没有关于 本机ip的授权 root@’172.17.194.166’
登陆mysql 查看连接:
mysql> desc information_schema.processlist;+———+———————+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+———+———————+——+—–+———+——-+
| ID | bigint(21) unsigned | NO | | 0 | |
| USER | varchar(16) | NO | | | |
| HOST | varchar(64) | NO | | | |
| DB | varchar(64) | YES | | NULL | |
| COMMAND | varchar(16) | NO | | | |
| TIME | int(7) | NO | | 0 | |
| STATE | varchar(64) | YES | | NULL | |
| INFO | longtext | YES | | NULL | |
+———+———————+——+—–+———+——-+
8 rows in set (0.01 sec)
mysql> select * from information_schema.processlist where user=’mycat’;
与max_connections有关的特性
mysql> show variables like ‘%connect%’;+———————————————–+—————–+
| Variable_name | Value |
+———————————————–+—————–+
| character_set_connection | utf8 |
| collation_connection | utf8_general_ci |
| connect_timeout | 10 |
| disconnect_on_expired_password | ON |
| init_connect | |
| max_connect_errors | 100 |
| max_connections | 2000 |
| max_user_connections | 0 |
| performance_schema_session_connect_attrs_size | 512 |
+———————————————–+—————–+
9 rows in set (0.00 sec)
MySQL无论如何都会保留一个用于管理员(SUPER)登陆的连接,用于管理员连接数据库进行维护操作,即使当前连接数已经达到了max_connections。因此MySQL的实际最大可连接数为max_connections+1;
这个参数实际起作用的最大值(实际最大可连接数)为16384,即该参数最大值不能超过16384,即使超过也以16384为准;
如何设置 max_connections
vim /etc/my.cnfmax_connections=2000
实时(临时)修改此参数的值
mysql> SELECT @@MAX_CONNECTIONS ; / select @@max_connections; / SELECT @@MAX_CONNECTIONS AS ‘Max Connections’;
+——————-+
| @@MAX_CONNECTIONS |
+——————-+
| 2000 |
+——————-+
1 row in set (0.00 sec)
mysql> set GLOBAL max_connections=2500;
Query OK, 0 rows affected (0.02 sec)
mysql> SELECT @@MAX_CONNECTIONS ;
+——————-+
| @@MAX_CONNECTIONS |
+——————-+
| 2500 |
+——————-+
1 row in set (0.00 sec)
相关文章推荐
- Jsp 中连接MySQL问题
- 如何在ASP中连接MySQL 数据库
- jsp连接Mysql乱码问题解决
- jsp和mysql连接
- asp.net中连接MYSQL
- 解决mysql不能和php连接,并提示1251错误
- 为MySQL Connector Net连接MySQL使用正确的连接字符串
- Jdeveloper 10g 里连接Mysql 数据库
- Jsp,JavaBean,Mysql的连接方法
- JSP 连接各类数据库大全(Oracle,MSSQL,DB2,Informix,SyBASE,MYSQL,PostgreSQL)
- Jsp 中连接MySQL
- 如何解决客户端与服务器端的连接(mysql) :xxx.xxx.xxx.xxx is not allowed to connect to this mysql serv
- Weblogic连接MySQL
- MySQL管理连接附件的安装
- 正好整理了一下,自己做了个连接数据库的组件,支持SQLSERVER,ACCESS,ORACLE,FoxPro,MySql,IBM DB2,DBF等数据库,并且支持事务处理
- Mysql中左连接的使用
- MYSQL 的JDBC连接测试程序
- jsp连接数据库---Mysql
- asp.net中连接MYSQL
- jsp 连接 mysql 数据库