mysql

Unable to convert MySQL.DateTime to System.DateTime with 0000-00-00 00:00:00 values

久未见 提交于 2021-02-07 20:40:47
问题 I am working on a C# project and I am facing an issue. The program allows the user to connect to a MySQL database and retrieve information from each selected table and write the data out to a file. The problem is because I have no idea what the schema is going to be like or what values its going to contain. If the timestamp column contains the date 0000-00-00 00:00:00 I get the conversion error and no matter what I try it never works. I've tried converting to a string I've tried converting to

Mariadb connection client: Access denied for user (using password: NO) on mysql 8.0

微笑、不失礼 提交于 2021-02-07 20:40:07
问题 mariadb-java-client throws access denied on mysql 8.0, but works on mysql 5.6 So I wonder if mariadb client is compatible with mysql 8.0 in mysql, test users are set limit to hosts machine = % even tested on mysql 8.0's machine, same access denied error. Caused by: java.sql.SQLException: Access denied for user 'user1'@'192.168.238.1' (using password: NO) Current charset is UTF-8. If password has been set using other charset, consider using option 'passwordCharacterEncoding' Connection

mysql5.7.20:安装教程

て烟熏妆下的殇ゞ 提交于 2021-02-07 20:34:52
从mysql官网下载安装包:/mysql-5.7.20-linuxglibc2.12-x86_64.tar.gz # 切换目录 cd /usr/ local # 解压下载的安装包 tar -zxvf /software/mysql/mysql- 5.7 . 20 -linux-glibc2. 12 -x86_64.tar. gz # 重命名 mv mysql- 5.7 . 20 -linux-glibc2. 12 - x86_64 mysql # 建立数据存储目录 mkdir data # 建立用户组 groupadd mysql # 建立用户,并禁止用户登录 useradd -r -s /sbin/nologin -g mysql mysql -d /usr/ local / mysql # 改变文件归属 chown -R mysql.mysql /usr/ local /mysql/ # 初始化系统数据库,记住不能用./bin/mysql_install_db,已经过期了 ./bin/mysqld --initialize --user=mysql --basedir=/usr/ local /mysql/ --datadir=/usr/ local /mysql/data/ 初始化后,会打印日志,如下 ,注意看最后输出,红色标记部分,这个就是root的临时密码。 2018 -

分布式事务有哪些解决方案?

↘锁芯ラ 提交于 2021-02-07 20:30:16
来源:http://dwz.date/eaAm 分布式事务是什么 数据库事务的特性包括原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Durabilily),简称 ACID。 在数据库执行中,多个并发执行的事务如果涉及到同一份数据的读写就容易出现数据不一致的情况,不一致的异常现象有以下几种。 脏读 ,是指一个事务中访问到了另外一个事务未提交的数据。例如事务 T1 中修改的数据项在尚未提交的情况下被其他事务(T2)读取到,如果 T1 进行回滚操作,则 T2 刚刚读取到的数据实际并不存在。 不可重复读 ,是指一个事务读取同一条记录 2 次,得到的结果不一致。例如事务 T1 第一次读取数据,接下来 T2 对其中的数据进行了更新或者删除,并且 Commit 成功。这时候 T1 再次读取这些数据,那么会得到 T2 修改后的数据,发现数据已经变更,这样 T1 在一个事务中的两次读取,返回的结果集会不一致。 幻读 ,是指一个事务读取 2 次,得到的记录条数不一致。例如事务 T1 查询获得一个结果集,T2 插入新的数据,T2 Commit 成功后,T1 再次执行同样的查询,此时得到的结果集记录数不同。 脏读、不可重复读和幻读有以下的包含关系,如果发生了脏读,那么幻读和不可重复读都有可能出现。 不同隔离级别 SQL 标准根据三种不一致的异常现象

How can I increment a column by one in a trigger?

主宰稳场 提交于 2021-02-07 20:28:10
问题 I need help writing a MySQL trigger. Suppose you have a student database with the following tables: ENROLLMENT(SSN, CLASS_NO, GRADE) CLASS(CLASS_NO, CLASS_TITLE, NO_OF_STUDENTS). I need to write a trigger to increase the NO_OF_STUDENTS by one if a new student is added to the ENROLLMENT table for that CLASS_NO . 回答1: you can use mysql trigger to do this. Try something like CREATE TRIGGER 'database_name'.'after_insert_enrollment' AFTER INSERT ON 'ENROLLMENT' FOR EACH ROW BEGIN UPDATE class SET

shorthand PDO query

旧巷老猫 提交于 2021-02-07 20:02:09
问题 Currently to perform a query with PDO, I use the following lines of code: $sql = "SELECT * FROM myTable WHERE id = :id"; $stmt = $conn->prepare($sql); $stmt->bindParam(':id', $id); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); And after some research, I found a shorter way of executing the same command: $stmt_test = $conn->prepare("SELECT * FROM status WHERE status_id = ?"); $stmt_test->execute([$id])->fetchAll(PDO::FETCH_ASSOC); $result = $stmt_test->fetchAll(PDO::FETCH

shorthand PDO query

梦想的初衷 提交于 2021-02-07 20:01:30
问题 Currently to perform a query with PDO, I use the following lines of code: $sql = "SELECT * FROM myTable WHERE id = :id"; $stmt = $conn->prepare($sql); $stmt->bindParam(':id', $id); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); And after some research, I found a shorter way of executing the same command: $stmt_test = $conn->prepare("SELECT * FROM status WHERE status_id = ?"); $stmt_test->execute([$id])->fetchAll(PDO::FETCH_ASSOC); $result = $stmt_test->fetchAll(PDO::FETCH

PHP how to check for email already in MySQL database?

孤人 提交于 2021-02-07 19:58:33
问题 Hi I'm calling out for help from all the PHP Gods on Stackoverflow :) I've created an email signup form (just 1 field for email), that is able to validate with Ajax and post a new email to the database from a basic PHP script I found. However the next step I have to do is check if an email is already in the database before adding it. There are several questions exactly like this on Stack and I've tried all the answers however to no avail :( I'm not a PHP guy and haven't been able to hack it

Safe way to store mysql server credentials in flask?

被刻印的时光 ゝ 提交于 2021-02-07 19:58:05
问题 I was wondering about the safety of some thing in my app.py flask app. First the database, I'm using mysql and currently I am connecting to it in the following way: # Config MySQL app.config['MYSQL_HOST'] = 'localhost' app.config['MYSQL_USER'] = 'root' app.config['MYSQL_PASSWORD'] = 'password' app.config['MYSQL_DB'] = 'databasename' app.config['MYSQL_CURSORCLASS'] = 'DictCursor' And to me this feels very weird, just putting in your password in plain text etc. I've been searching online but

mySQL correlated Subquery

徘徊边缘 提交于 2021-02-07 19:56:33
问题 trying to write a mysql query and having a lot of difficult with this one. I have two tables( Item: info about items, and itemReview: reviews for the items ) What I would like to do is select all the items that belong to a particular location (which is what my outer query does) and then for each item in the outer query, get the average of all the rating fields in the itemReview table Here is my attempt: SELECT Item.idDish, Item.dateAdded, Item.dateModified, Item.fidLocation, Item.category,