MySQL Client

Installing mysql server on Centos 7 在 Linux上安装

眉间皱痕 提交于 2020-04-26 18:05:19
You should install only one MySQL version on your CentOS 7 server. If you are not sure which version to install consult the documentation of the applications you’re going to deploy on your server. Install MySQL 8.0 on CentOS 7 At the time of writing this article, the latest version of MySQL is version 8.0. To install it on your CentOS 7 server follow the steps below: Enable the MySQL 8.0 repository with the following command: sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm Install MySQL 8.0 package with yum: sudo yum install mysql-community-server

django模型(1)

旧巷老猫 提交于 2020-04-26 15:31:42
03-django模型(1) 一、内容回顾   1、路由层     a、简单使用     b、有名分组     c、路由分发     d、反向解析   2、视图层     a、HttpRequest对象 常用的属性 常用方法     b、HttpResponse对象       响应三剑客   3、模板层     a、模板之变量     b、模板之过滤器     c、模板之标签     d、自定制标签和过滤器     e、模版继承 二、今日概要   1、ORM简介   2、单表操作 三、今日详细   1、ORM简介     对象关系映射(Object Relational Mapping,简称ORM)。     简单的说,ORM是通过使用描述对象和数据库之间映射的元数据,将程序中的对象自动持久化到关系数据库中。     ORM在业务逻辑层和数据库层之间充当了桥梁的作用。     咱们通过一张图来介绍一下数据库与python代码之间的一个关系,请看下图:     ORM的优点: 不用写繁琐的SQL语句,用咱们熟悉的python代码,就能实现对数据的操作,提高开发效率; 可以平滑的操作,切换数据库。     ORM的缺点: ORM代码转换为SQL语句时,需要花费一定的时间,执行效率会有所降低; 长期写ORM代码,导致写SQL语句能力,会有所减弱。     

(转载)用C#实现MySQL建库及建表

早过忘川 提交于 2020-04-25 13:54:16
最近做一个项目,为了方便用户使用,希望可以在系统初始化的时候,自动实现 MySQL 数据库 的建库和建表操作。在网上查了很多资料都没有找到合适的,偶尔在一个国外网站上看到了相关的内容,特把实现方法整理如下: 1、用C#实现MySQL建库 [csharp] view plain copy using System.Drawing; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace MySqlDemo { /// <summary> /// 实现MySQL建库 /// </summary> public class Form1 : System.Windows.Forms.Form { void btnCreateDB( object sender, System.EventArgs e) { MySqlConnection conn = new MySqlConnection( "Data Source=localhost;Persist Security Info=yes;UserId=root; PWD=你的密码;" ); MySqlCommand cmd = new MySqlCommand( "CREATE DATABASE 你的数据库名;" , conn ); conn.Open();

Mysql操作类封装【https://blog.csdn.net/blog_lee/article/details/45111489】

孤街醉人 提交于 2020-04-25 13:53:59
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Configuration; using System.Windows.Forms; using MySql.Data.MySqlClient; using System.Xml; using MySql.Data; /* * Author: Lee * Time: 2015-04-08 * Info: 数据库封装操作类 */ namespace Common { public class DbManager { //连接用的字符串 private string connStr; public string ConnStr { get { return this.connStr; } set { this.connStr = value; } } private DbManager() { } //DbManager单实例 private static DbManager _instance = null; public static DbManager Ins { get { if (_instance == null) { _instance =

刨根问底,完美解决Django2版本连接MySQL报错的问题

ぃ、小莉子 提交于 2020-04-23 03:28:14
引子 关于Django2版本连接MySQL发生的问题以及修改源码的解决方法参考下面这篇文章: Django与MySQL的交互 但是,上面这种修改源码的方法在生产环境中使用的话会有很多问题。 本文为大家详细讲解如何在不修改Django源码的情况下解决这个问题。 Django中的源码解析 我们来看一下我们使用的Python解释器(可以是全局的也可以是虚拟环境的)中django包有关MySQL配置的源码。 源码位置是: (你的Python解释器安装目录或者虚拟环境目录)\django21\Lib\site-packages\django\ db\backends\mysql\ base .py 这个base.py文件中的内容有点多,我们把最关键的部分挑出来解释一下: """ MySQL database backend for Django. Requires mysqlclient: https://pypi.org/project/mysqlclient/ # 之前没安装的话得从pypi中下载mysqlclient包 """ import re from django.core.exceptions import ImproperlyConfigured from django.db import utils from django.db.backends import utils

SQLAlchemy 基础知识

 ̄綄美尐妖づ 提交于 2020-04-19 18:16:04
全栈工程师开发手册 (作者:栾鹏) python教程全解 SQLAlchemy 基础 下面是一段官方 SQLAlchemy 使用示例,我们从这个例子出发,认识 SQLAlchemy。 from sqlalchemy import create_engine from sqlalchemy import Column, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker # sqlite3/mysql/postgres engine # 请先自己在 MySQL 中创建一个名为 test_tmp 的 database engine = create_engine('mysql://root@localhost/test_tmp', echo=False) Base = declarative_base() Session = sessionmaker(bind=engine) session1 = Session() session2 = Session() SessionNoAutoflush = sessionmaker(bind=engine, autoflush=False) session3 =

小白学 Python 爬虫(31):自己构建一个简单的代理池

喜夏-厌秋 提交于 2020-04-18 00:18:15
人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Linux基础入门 小白学 Python 爬虫(4):前置准备(三)Docker基础入门 小白学 Python 爬虫(5):前置准备(四)数据库基础 小白学 Python 爬虫(6):前置准备(五)爬虫框架的安装 小白学 Python 爬虫(7):HTTP 基础 小白学 Python 爬虫(8):网页基础 小白学 Python 爬虫(9):爬虫基础 小白学 Python 爬虫(10):Session 和 Cookies 小白学 Python 爬虫(11):urllib 基础使用(一) 小白学 Python 爬虫(12):urllib 基础使用(二) 小白学 Python 爬虫(13):urllib 基础使用(三) 小白学 Python 爬虫(14):urllib 基础使用(四) 小白学 Python 爬虫(15):urllib 基础使用(五) 小白学 Python 爬虫(16):urllib 实战之爬取妹子图 小白学 Python 爬虫(17):Requests 基础使用 小白学 Python 爬虫(18):Requests 进阶操作 小白学 Python 爬虫(19):Xpath 基操

MySQL 8.0.19客户端的一个小变化

梦想的初衷 提交于 2020-04-06 11:54:18
本文作者:叶金荣,知数堂联合创始人,MySQL DBA课程讲师。Oracle MySQL ACE,MySQL布道师。有多年MySQL及系统架构设计经验,擅长MySQL企业级应用、数据库设计、优化、故障处理等。 不注意到这个变化的话,还挺折腾人的。 在MySQL 8.0.19 Release Notes里,有这么一段话: When the mysql client operates in interactive mode, the --binary-as-hex option now is enabled by default. In addition, output from the status (or \s) command includes this line when the option is enabled implicitly or explicitly。To disable hexadecimal notation, use --skip-binary-as-hex (Bug #24432545) 意思是如果用mysql客户端进入交互模式,那么默认启用参数 --binary-as-hex ,执行 status 或 \s 时能看到下面这样的标记: [root@yejr.me]> \s ... Binary data as: Hexadecimal ...

学习猿地 python教程 django教程2 模型配置及案例

只愿长相守 提交于 2020-03-23 12:00:51
3 月,跳不动了?>>> ## M ==> Model ==> 模型层 > 数据管理层 对数据的相关操作和管理 ### 给当前的项目配置一个数据库 1.确认当前是否安装了mysql数据库 2.在mysql数据库中创建一个库 mydb `create database mydb default charset=utf8mb4;` 3.修改当前项目中的数据库配置 settings.py/DATABASES ```python DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mydb',#选择数据库的名,请确认你的mysql中有这个库 'USER': 'root', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '3306', } } ``` 4.如果当前环境中没有安装MySQLDB的替代包,会报错 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? 解决方法: 1.安装 mysqlclient `pip install mysqlclient` 2.安装 pymysql 安装后需要配置 ##

mysql 夯hang死堆栈采集工具

江枫思渺然 提交于 2020-03-09 15:57:57
这里我们的场景是mysql client已经无法登陆,无法执行sql。 基本思路是打出堆栈来分析 此时首先怀疑mysql内部发生了死锁 1. 使用pstack打出堆栈,会有一定性能影响 yum install gdb pstack mysql_pid > /tmp/pstack.out 也可以用gdb gdb -batch -ex "thread apply all bt" -p mysql_pid > /tmp/gdb.log 堆栈可能比较多,需要耐心一点点排查,找出死锁的调用路径 2. 使用strace打出一段时间内的系统调用信息,会有一定性能影响 strace -o /tmp/strace_output.txt -T -tt -f -e trace=all -p {mysql_pid} 可以作为额外信息,辅助堆栈的排查 如果pstack或gdb也无法进入,那可能mysql已经不响应信号了 只能从操作系统提供的proc文件收集一些信息 cat /proc/mysql_pid/status 注意,status里除了进程状态之外,也有信号处理相关的信息Sig* cat /proc/mysql_pid/task/*/stack cat /proc/mysql_pid/syscall cat /proc/mysql_pid/stack 当前的系统调用信息