mysql

趣图:MySQL = 没压岁钱了

爱⌒轻易说出口 提交于 2021-02-18 13:18:10
程序员的成长之路 互联网/程序员/技术/资料共享 关注 阅读本文大概需要 2.8 分钟。 辛丑牛年来了,祝大家新春快乐 MySQL = 没压岁钱了 ↓↓↓ 我是真的没有压岁钱收了 还能收的盆友都收到多少呀?来说说呗 <END> 推荐阅读: 微信昵称加「福」字,最新官方攻略来了! 微信官宣:5000W个微信红包封面,可以秀一波了!! 5T技术资源大放送!包括但不限于:C/C++,Linux,Python,Java,PHP,人工智能,单片机,树莓派,等等。在公众号内回复「 2048 」,即可免费获取!! 微信扫描二维码,关注我的公众号 朕已阅 本文分享自微信公众号 - 程序员的成长之路(cxydczzl)。 如有侵权,请联系 support@oschina.cn 删除。 本文参与“ OSC源创计划 ”,欢迎正在阅读的你也加入,一起分享。 来源: oschina 链接: https://my.oschina.net/u/4581745/blog/4953799

python实时监控服务器性能

跟風遠走 提交于 2021-02-18 12:54:40
监控服务器各项性能指标,以下为监控测试流程 1、mysql数据库插入数据 1.1 大家要首先在服务器上安装一个mysql,此项略。。。 1.2 登录mysql新建一个cpu库和cpu表 1.3 连接数据库,代码如下 1 import pymysql 2 class Conn: 3 def __init__ (self): 4 self.connect = pymysql.connect( 5 host = " 192.168.1.124 " , 6 port = 3306 , 7 user = " root " , 8 passwd = " testmysql " , 9 db = " cpu " , 10 charset = " utf8 " 11 ) 12 self.cur = self.connect.cursor() 13 14 def insert(self,data): 15 sql = " insert into cpu(cpu_idle,memory_used,memory_free,disk_C_free) values ('%s','%s','%s','%s') " 16 self.cur.execute(sql% data) 17 # self.connect.close() 18 self.connect.commit() 19 20 # if __name

Mysql字符串截取函数

…衆ロ難τιáo~ 提交于 2021-02-18 12:32:22
有时候我们需要直接用MySQL的字符串函数截取字符,毕竟用程序截取(如PHP)还得先写个脚本连接数据库之类的,所以在这里做一个记录,希望对大家有用。 1、从左开始截取字符串 left(str, length) 说明:left(被截取字段,截取长度) 例: select left (content, 200 ) as abstract from my_content_t 2、从右开始截取字符串 right(str, length) 说明:right(被截取字段,截取长度) 例: select right (content, 200 ) as abstract from my_content_t 3、截取字符串 substring(str, pos) substring(str, pos, length) 说明:substring(被截取字段,从第几位开始截取) substring(被截取字段,从第几位开始截取,截取长度) 例: select substring (content, 5 ) as abstract from my_content_t select substring (content, 5 , 200 ) as abstract from my_content_t (注:如果位数是负数 如-5 则是从后倒数位数,到字符串结束或截取的长度) 4、按关键字截取字符串

Running mysql_upgrade in Docker?

别说谁变了你拦得住时间么 提交于 2021-02-18 12:23:26
问题 I was trying to create a user using: docker exec -i database mysql -uroot -proot -e "CREATE USER 'dbadmin'@'%'" However I ran into this ERROR: ERROR 1054 (42S22) at line 1: Unknown column 'password_last_changed' in 'mysql.user' 回答1: After googling for a few hours, I found the answer in this blog post: docker exec -it container_name bash -c "mysql_upgrade -uroot -proot" root must be your mysql username and password 来源: https://stackoverflow.com/questions/40981983/running-mysql-upgrade-in

JPA Native query get a Single Object

佐手、 提交于 2021-02-18 12:17:06
问题 How can i get a single object by using JPA Native query. I did some researches but all give an answer is use "getSingleResult", however it didn't return what i want to get. For example, what should i do if i want to get a count of table in my database and fetch it into a Integer. This code below shows how i get this by using Sessison hibernate: int check = Integer.parseInt((String) sessionF.createSQLQuery("select to_char(count(*)) as count from user_tables where table_name upper('TEST')")

How to display mysql blob image in html using Vuejs?

走远了吗. 提交于 2021-02-18 12:16:28
问题 I have a vue file like this, export default { data(){ return{ info: { name: '', image: '', }, errors: [] } }, created: function(){ this.getInfo(); }, methods: { getInfo: function(){ this.info.name = response.data.results[0].name; this.info.image = response.data.results[0].image; } } } I am passing data from this file into a child Vue component. The child component is as follows, <template> <div class="ui items"> <div class="item"> <div class="ui small image"> {{info.image}} </div> </div> <

django python collation error

两盒软妹~` 提交于 2021-02-18 12:08:47
问题 What is the reason for the following error? when i try to filter with: if MyObject.objects.filter(location = aDictionary['address']): where location is defined as: location = models.CharField(max_length=100, blank=True, default='') I get the following error when aDictionary['address'] contains a string with a non-alphanumeric character (for example Kīhei): File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaul terrorhandler raise errorclass, errorvalue _mysql

mysql流程控制函数

大憨熊 提交于 2021-02-18 11:46:56
MySQL处理函数之流程控制函数 May 5, 2016 3:44:45 PM luo 638 摘要 :MySQL内置函数之流程控制函数整理。MySQL中列可以将字段看作变量来使用,变量的值就是这个列对应的每一行的记录。 [TOC]    MySQL中列可以将字段看作变量来使用,变量的值就是这个列对应的每一行的记录。   在使用select,update,delete语句以及子句where、order by、having中,我们可以使用MySQL内置函数。 流程控制函数 CASE WHEN THEN 函数 语法: CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result ……] [ELSE result ] END CASE WHEN [condition] THEN result [WHEN[condition] THEN result ……] [ELSE result] END ; 函数用法说明:   1. 在第一个方案的返回结果中, value=compare-value 。   2. 而第二个方案的返回结果是第一种情况的真实结果。如果没有匹配的结果值,则返回结果为 ELSE 后的结果,如果没有 ELSE 部分,则返回值为 NULL。 示例 mysql> SELECT CASE

How to use 'where' on column with comma separated values in laravel

倖福魔咒の 提交于 2021-02-18 11:20:07
问题 I am using php with laravel framework. I want to get rows from table that contains user id. Problem here is that user id is integer value and column(author) contain more than one comma separated integer values. Here is example. DB::table('stories')->where('author','4')->get(); author column have values : row 1: 2,4,5 | row 2: 1,3,14 | row 3 : 4,5 and I will get row 1 and 3. So, Please help me to get right rows. 回答1: You can use whereRaw like as DB::table('stories')->whereRaw("find_in_set('4'

MySQL keeps crashing

寵の児 提交于 2021-02-18 11:19:30
问题 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