mariadb

How to add a virtual column with the schema builder?

倖福魔咒の 提交于 2020-01-02 04:37:09
问题 I'm creating a table like this, Schema::create('booking_segments', function (Blueprint $table) { $table->increments('id'); $table->datetime('start')->index(); $table->integer('duration')->unsigned(); $table->string('comments'); $table->integer('booking_id')->unsigned(); $table->foreign('booking_id')->references('id')->on('bookings')->onDelete('cascade'); }); But I want to add one extra column. It looks like this in raw SQL: ALTER TABLE booking_segments ADD COLUMN `end` DATETIME AS (DATE_ADD(

Laravel 5.4 gives Wrong COM_STMT_PREPARE response size

青春壹個敷衍的年華 提交于 2020-01-01 03:30:37
问题 I'm working on a website and it worked fine the past month, suddenly yesterday it crashed and says Wrong COM_STMT_PREPARE response size. Received 7 . This is my code in the controller: public function newsFeed() { // get all data needed for the news page try{ $news = DB::SELECT("SELECT n.newId ,n.title_en ,n.title_es ,n.description_en ,n.description_es ,n.newMainImg ,n.tags ,DATE_FORMAT(n.createDate, '%b - %e - %Y') as publishDate_en ,DATE_FORMAT(n.createDate, '%e - %b - %Y') as publishDate

mariadb/mysql高可用读写分离

家住魔仙堡 提交于 2020-01-01 01:29:25
第一步mariadb主从配置 第二步ProxySql读写分离 第三步keepalived高可用proxysql 第四步测试mysql读写分离高可用是否成功 第一步mariadb主从配置: 首先配置好mariadb主从同步,这里采用的一主两从,node1和node2为半同步复制,node1和node3为异步复制,也可以全部采用异步复制,根据业务需求配置即可 保证各服务器节点时间同步,可参考 时间同步设置方案 http://www.longma.tk/p=629 初始化环境 node1和 node2 ,为保证不受其它实验干扰,建议恢复至初始状态,新装的mariadb即可,不要有其它实验项目干扰 主服务器node1配置: 1 2 3 4 5 6 7 8 9 10 11 配置文件 vim / etc / my .cnf .d / server .cnf [ mysqld ] skip_name_resolve = ON innodb_file_per_table = ON server_id = 1 log_bin = mysql - bin systemctl start mariadb .service mysql > GRANT REPLICATION SLAVE , REPLICATION CLIENT ON * . * TO 'repluser' @ '172.18.43.%'

MariaDB on Windows - what is this error when trying to start the database engine?

一个人想着一个人 提交于 2020-01-01 01:16:08
问题 I am asking this question as an offshoot myself and another SO had from this other MariaDB question: MariaDB on Windows - getting started help? When I install MariaDB (v5.2.4), open the command window, navigate to the folder where the files are installed, and type in the following to start the database: net start mysql I get the following error: the service name is invalid I didn't do anything complex, just ran the installation and tried to get started. Any ideas? 回答1: The error basically

Completely remove MariaDB or MySQL from CentOS 7 or RHEL 7

不打扰是莪最后的温柔 提交于 2019-12-31 08:24:06
问题 I installed MariaDB on CentOS 7 but I had some problems with some configuration, now it is completely misconfigured. Thus, I wanted to remove the MariaDB with “yum remove mariadb mariadb-server”, after that I reinstalled it with “yum install mariadb mariadb-server”. Unfortunately, the configuration remains. It seems as if yum remove don’t delete all MariaDB Config-Files. How can I remove MariaDB completely from CentOS 7? 回答1: These steps are working on CentOS 6.5 so they should work on CentOS

Why does MYSQL DB return a corrupted value when averaging over a Django models.DateTimeField?

天大地大妈咪最大 提交于 2019-12-31 07:10:32
问题 I'm running a Django application on top of a MySQL (actually MariaDB) database. My Django Model looks like this: from django.db import models from django.db.models import Avg, Max, Min, Count class myModel(models.Model): my_string = models.CharField(max_length=32,) my_date = models.DateTimeField() @staticmethod def get_stats(): logger.info(myModel.objects.values('my_string').annotate( count=Count("my_string"), min=Min('my_date'), max=Max('my_date'), avg=Avg('my_date'), ) ) When I run get

How to get a django template to pull information from two different models?

旧城冷巷雨未停 提交于 2019-12-31 05:51:41
问题 I am coding a basic django application that will show a table of current store sales, based off of information from a MariaDB database. The data is entered into the database through a seperate process, so it isn't created in Django, it is just using a simple python script to load a csv file and parse it into an Insert query. There are two models in my code, Stores and ShowroomData. Showroomdata holds all of the records from the python script, however it does not hold any store information. I

How to get a django template to pull information from two different models?

心不动则不痛 提交于 2019-12-31 05:51:06
问题 I am coding a basic django application that will show a table of current store sales, based off of information from a MariaDB database. The data is entered into the database through a seperate process, so it isn't created in Django, it is just using a simple python script to load a csv file and parse it into an Insert query. There are two models in my code, Stores and ShowroomData. Showroomdata holds all of the records from the python script, however it does not hold any store information. I

Hierarchical Query in MySQL. (connect by equivalent for MySQL)

◇◆丶佛笑我妖孽 提交于 2019-12-31 05:20:07
问题 I have three fields in a table that define a hierarchical relationship present in a MySQL database. Table Name : tb_corp -------------------------------------------- comp_code | incharge_comp_Code | mngr_emp_no A | | 111 -------------------------------------------- B | A | -------------------------------------------- C | B | -------------------------------------------- How do I write a query to obtain all the comp_code that mngr_emp_no = 111 is in charge. According to the table above, 111 is

Why am I getting the error 1064 (42000) while importing using MariaDB/“mysql shell”?

你离开我真会死。 提交于 2019-12-31 03:51:07
问题 Whenever I try import a database.csv, I get this: http://prntscr.com/eo5eyg Syntax error at line 1. I typed mysql -u root tatoeba3 < tatoeba_database.sql tatoeba3 is the database file (.csv) tatoeba_database.sql is the "final destination" Alsom where should I put tatoeba3? For now, it's at C:\xampp\htdocs\tatoeba2 I'm doing according the following: https://github.com/Tatoeba/tatoeba2/wiki/How-to-install-Tatoeba MariaDB [(none)]> mysql -u root tatoeba3 < tatoeba_database.sql; ERROR 1064 (42000