我已经在PHP中使用PDO一段时间了,现在正在使用MySQL.
然而,最近的发展使我认为MySQL将开始逐渐淡出以取代MariaDB,尤其是自MariaDB以来:
所以我的问题是,因为MariaDB似乎没有列在PDO驱动程序中,并且因为MariaDB被设计为"替代品"并且可能在将来逐步淘汰MySQL.
我是否可以将MySQL PDO驱动程序与MariaDB数据库一起使用,至少在官方MariaDB驱动程序可用之前?
链接
我有以下内容:
import MySQLdb as dbapi
import sys
import csv
dbServer='localhost'
dbPass='supersecretpassword'
dbSchema='dbTest'
dbUser='root'
dbQuery='SELECT * FROM pbTest.Orders;'
db=dbapi.connect(host=dbServer,user=dbUser,passwd=dbPass)
cur=db.cursor()
cur.execute(dbQuery)
result=cur.fetchall()
c = csv.writer(open("temp.csv","wb"))
c.writerow(result)
Run Code Online (Sandbox Code Playgroud)
这会产生乱码.我熟悉使用打印记录[0]等.不知道我应该如何设置格式.产生类似查询在控制台中的内容.我不能从mysql服务器做一个简单的INTO OUTFILE.
我在寻找解决方案如何更新mariadb在xampp 32 bit视窗系统上,但没有发现任何that.I文章刚刚发现这个链接.请帮我看看如何更新.我要JSON支持,这就是为什么我从寻找更新V10.1到V10.2.或者,如果有任何其他方法,请告诉我
目前的版本是 10.1.19-MariaDB
我的Java代码出现此错误
Caused by :`com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException`: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB` server version for the right syntax to use near 'type = `MyISAM`' at line 1
Run Code Online (Sandbox Code Playgroud)
这是hibernate传递的查询:
Hibernate: create table EMPLOYEE (emp_id integer not null, FNAME varchar(255), LNAME varchar(255), primary key (emp_id)) type=MyISAM
Run Code Online (Sandbox Code Playgroud)
我查看了与此错误相关的所有问题.但是在所有问题中,用户本身都在传递查询" type = MyISAM",因此他们可以将" type"改为" engine",但是这里hibernate负责创建表,所以我不明白错误在哪里,以及我如何解决它.
这是我的配置文件:
<hibernate-configuration>
<session-factory >
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/servletcheck</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"> </property>
<property name="hibernate.dialect"> org.hibernate.dialect.MySQLDialect</property>
<property …Run Code Online (Sandbox Code Playgroud) 我想通过设置root密码来保护mysql.我成功重置了root密码:
MariaDB [(none)]> select Host, User, Password from mysql.user;
+-----------+------+-------------------------------------------+
| Host | User | Password |
+-----------+------+-------------------------------------------+
| localhost | root | *58319282EAB9E38D49CA25844B73DA62C80C2ABC |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
但是,在刷新权限后,重新启动Mysql,我仍然可以在不输入密码的情况下登录mysql(在本地主机上).
root@myhost:/# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.0.29-MariaDB SLE 12 SP1 package
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the …Run Code Online (Sandbox Code Playgroud) 我有一个使用 mysqldump 从 AWS RDS MariaDB 导出数据的流程,该流程已在 Concourse 上的 docker-image 中成功运行多年。
从两天前开始,该过程开始失败并出现以下错误:
mysqldump: Couldn't execute 'FLUSH TABLES WITH READ LOCK': Access denied for user 'admin'@'%' (using password: YES) (1045)
Run Code Online (Sandbox Code Playgroud)
AWS的官方解释似乎是,因为它们不允许主用户或全局读锁的超级权限,所以如果设置了 --master-data 选项,mysqldump 就会失败。
我没有设置该选项。我正在使用这些标志运行:
mysqldump -h ${SOURCE_DB_HOST} ${SOURCE_CREDENTIALS} ${SOURCE_DB_NAME} --single-transaction --compress | grep -v '^SET .*;$' > /tmp/dump.sql
Run Code Online (Sandbox Code Playgroud)
从我的本地 Mac 执行时 mysqldump 工作正常。它失败并出现错误,无法仅从 Linux 环境执行 FLUSH TABLES WITH READ LOCK。
我的问题是,有谁知道如何在 Linux 上的 mysqldump 中禁用 FLUSH TABLES WITH READ LOCK 命令?
编辑:很高兴接受下面的 @sergey-payu 答案,因为它已经解决了我的问题,但这里有一个 MySQL 错误报告的链接,以供遇到此问题的其他人使用https://bugs.mysql.com/bug.php? id=109685
我需要修改文件/etc/httpd/conf.d/phpMyAdmin.conf
以允许远程用户(不仅是localhost)登录
# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory> …Run Code Online (Sandbox Code Playgroud) 我正在努力在系统范围内或在安装了MariaDB 10的Ubuntu 14.04上的venv中安装mysql-python pip.还尝试使用MariaDB 5.5并获得相同的错误.我没有安装vanilla mysql-server这个问题.
我通过apt-get安装了以下内容:
最初我认为这是一个安装到venv中的问题,但我后来发现mysql-python也不会在全系统安装.下面是我用来安装在venv中的cmds.
virtualenv venv
. venv/bin/activate
pip install mysql-python==1.2.5
In file included from _mysql.c:44:0:
/usr/include/mysql/my_config.h:439:0: warning: "HAVE_WCSCOLL" redefined [enabled by default]
#define HAVE_WCSCOLL
^
In file included from /usr/include/python2.7/pyconfig.h:3:0,
from /usr/include/python2.7/Python.h:8,
from _mysql.c:29:
/usr/include/x86_64-linux-gnu/python2.7/pyconfig.h:911:0: note: this is the location of the previous definition
#define HAVE_WCSCOLL 1
^x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmariadbclient_r -lpthread …Run Code Online (Sandbox Code Playgroud) 我登录MariaDB/MySQL并输入:
SHOW COLLATION;
Run Code Online (Sandbox Code Playgroud)
我看到的utf8mb4_unicode_ci和utf8mb4_unicode_520_ci可用的排序规则之一.这两种排序规则之间有什么区别,我们应该使用哪种排序规则?
我正在尝试在Ubuntu 12.04 LTS上安装MariaDB.
我按照https://askubuntu.com/questions/64772/how-to-install-mariadb和MariaDB.org 提供的说明进行选择下载.
最后一步是sudo apt-get install mariadb-server返回:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mariadb-server : …Run Code Online (Sandbox Code Playgroud)