mysql

MySQL keeps crashing

非 Y 不嫁゛ 提交于 2021-02-18 11:17:18
问题 I Have a server in the cloud running Ubuntu 12.10, with 512Mb of RAM just to run a wordpress website (with approx 1000 visits/day). MySQL was always crashing then I enabled a 4Gb swap to see if can works... but still crashing... and I need to restart the service every time... Checking the error log from mysql I noticed that InnoDB appears to be in a loop trying to recover something but I think it can't... can anyone help me? 131009 17:56:57 InnoDB: 5.5.32 started; log sequence number

Mysql count rows using filters on high traffic database

情到浓时终转凉″ 提交于 2021-02-18 10:49:06
问题 Let's say you have a search form, with multiple select fields, let's say a user selects from a dropdown an option, but before he submits the data I need to display the count of the rows in the database . So let's say the site has at least 300k(300.000) visitors a day, and a user selects options from the form at least 40 times a visit, that would mean 12M ajax requests + 12M count queries on the database, which seems a bit too much . The question is how can one implement a fast count (using

How to access mysql database using shell script?

元气小坏坏 提交于 2021-02-18 10:38:45
问题 Is there a way I can access MySQL database using shell script? want to do some selects and some inserts on multiple tables? It will be great if you can give some sample code as I am new to scripting. 回答1: This link seems to have the information you want. http://www.cyberciti.biz/faq/using-mysql-in-shell-scripts/ mysql -u user -p dbnane 回答2: try this #!/bin/bash echo "show all tables" mysql -uroot -p'password' dbname<<EOFMYSQL show tables; EOFMYSQL echo "Count of all records" mysql -uroot -p

How to listen new db records through java

女生的网名这么多〃 提交于 2021-02-18 08:33:27
问题 Currently I use while(true) and Thread.sleep() for checking for new records in the db and execute java code. Here is an example: public class StartCommands implements Runnable{ private Active_Job activeJob; Runnable execute_command; public StartCommands(){ activeJobs = new Active_Job(); } @Override public void run(){ int jobId = 0; while(true){ //access the db and get one row from the table by the status jobId = activeJobs.get(Status.NEW); if (jobId > 0){ activeJob.updateStatus(Status.INIT);

MySQL Workbench 6.0 error could not acquire managemant access for the administrator?

不打扰是莪最后的温柔 提交于 2021-02-18 07:57:07
问题 I am using MySQL Workbench 6.0 over here. When I select the server status, I am getting this error Regarding this, I tried looking for solutions on Google and StackOverflow ( e.g. this result ) But here in MySQL Workbench 6.0, I don't know where is Server Administration of Mysql's and Workbench Central . Can anyone help me regarding this issue in MySQL Workbench 6.0? 回答1: Try running chcp in a terminal window (command line window). Does it run there? It should print out the current code page.

Docker应用容器引擎

拜拜、爱过 提交于 2021-02-18 07:39:02
1.Docker概述 1.1.Docker简介 Docker 是一个开源的应用容器引擎,基于 Go 语言开发。Docker 可以让开发者打包他们的应用以及依赖包到一个轻 量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互 之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低。 · Docker应用场景 Web 应用的自动化打包和发布 自动化测试和持续集成、发布 在服务型环境中部署和调整数据库或其他的后台应用 使用Docker可以实现开发人员的开发环境、测试人员的测试环境、运维人员的生产环境的一致性。 1.2. Docker容器与传统虚拟机比较 传统虚拟机 传统虚拟机技术 基于安装在主操作系统上的虚拟机管理系统(如:VirtualBox和VMWare等),创建虚拟机(虚拟出 各种硬件),在虚拟机上安装从操作系统,在从操作系统中安装部署各种应用。 Docker Docker容器 是在操作系统层面上实现虚拟化,直接复用本地主机的操作系统,而传统虚拟机则是在硬件层面实现虚 拟化。与传统的虚拟机相比,Docker优势体现为启动速度快、占用体积小。 1.3. Docker组成部分 2. Docker安装与启动 Docker可以运行在MAC、Windows、CentOS、DEBIAN、UBUNTU等操作系统上

上亿数据怎么玩深度分页?兼容MySQL + ES + MongoDB

别来无恙 提交于 2021-02-18 07:36:41
面试题 & 真实经历 面试题 :在数据量很大的情况下,怎么实现深度分页? 大家在面试时,或者准备面试中可能会遇到上述的问题,大多的回答基本上是 分库分表建索引 ,这是一种很 标准的正确回答 ,但现实总是很骨感,所以面试官一般会追问你一句, 现在工期不足,人员不足,该怎么实现深度分页? 这个时候没有实际经验的同学基本麻爪,So,请听我娓娓道来。 惨痛的教训 首先必须明确一点 :深度分页可以做,但是 深度随机跳页绝对需要禁止。 上一张图: 你们猜,我点一下第 142360 页,服务会不会爆炸? 像 MySQL , MongoDB 数据库还好,本身就是专业的数据库,处理的不好,最多就是慢,但如果涉及到 ES ,性质就不一样了,我们不得不利用 SearchAfter Api,去循环获取数据,这就牵扯到内存占用的问题,如果当时代码写的不优雅,直接就可能导致内存溢出。 为什么不能允许随机深度跳页 从技术的角度浅显的聊一聊为什么不能允许随机深度跳页,或者说为什么不建议深度分页 MySQL 分页的基本原理: SELECT * FROM test ORDER BY id DESC LIMIT 10000, 20; LIMIT 10000 , 20的意思扫描满足条件的10020行,扔掉前面的10000行,返回最后的20行。如果是LIMIT 1000000 , 100,需要扫描1000100 行

Image upload/receive API

你说的曾经没有我的故事 提交于 2021-02-18 07:34:08
问题 I'd like to offer a simple API on my website that allows people to upload images to it (and receive the URL to access it). But I have several questions: Would it be better if the user would have to send the image in binary code or would it be better if the user would have to send it in idk ASCII or so? What is the conventional way? (I'm asking that because I can imagine that some languages only have functions to read files as textfiles.) Where do I store the images on the server and how? Can

MySQL - How to use a variable as column name

故事扮演 提交于 2021-02-18 07:04:25
问题 I want to use a registry as a column name but the registry is variable and I don't know when it changes. Example: Config (field) = 'Medicine' FieldContent (another field) = 'Remedy name' A want to make this: Medicine (use content of Config as column name) = 'Remedy Name' (as registry) What have I tried? SET @CONFIG = SELECT CONFIG; SELECT FIELDCONTENT AS @CONFIG FROM TABLENAME; MySql says that I can't use a variable as column name. There's other way? actual Config Content Medicine RemedyName

为什么 Redis 要比 Memcached 更火?

混江龙づ霸主 提交于 2021-02-18 04:06:32
作者:Kaito 链接:kaito-kidd.com/2020/06/28/redis-vs-memcached/ 前言 我们都知道,Redis和Memcached都是内存数据库,它们的访问速度非常之快。但我们在开发过程中,这两个内存数据库,我们到底要如何选择呢?它们的优劣都有哪些? 为什么现在看Redis要比Memcached更火一些? 这篇文章,我们就从各个方面来对比这两个内存数据库的差异,方便你在使用时,做出最符合业务需要的选择。 要分析它们的区别,主要从以下几个方面对比: 线程模型 数据结构 淘汰策略 管道与 事务 持久化 高可用 集群化 线程模型 要说性能,必须要分析它们的服务模型。 Memcached处理请求采用多线程模型,并且基于IO多路复用技术,主线程接收到请求后,分发给子线程处理。 这样做好的好处是,当某个请求处理比较耗时,不会影响到其他请求的处理。 当然,缺点是CPU的多线程切换必然存在性能损耗,同时,多线程在访问共享资源时必然要加锁,也会在一定程度上降低性能。 Redis同样采用IO多路复用技术,但它处理请求采用是单线程模型,从接收请求到处理数据都在一个线程中完成。 这意味着使用Redis,一旦某个请求处理耗时比较长,那么整个Redis就会阻塞住,直到这个请求处理完成后返回,才能处理下一个请求,使用Redis时一定要避免复杂的耗时操作。 单线程的好处是