wordpress 数据库链接失败

今天访问网站,才发现直接提示数据库链接失败

查看mysql的

2019-01-21T03:23:15.998898Z 15638 [ERROR] /usr/sbin/mysqld: Table ‘./mybacc_wordpress/wp_options’ is marked as crashed and last (automatic?) repair failed
2019-01-21T03:23:15.999066Z 15638 [ERROR] /usr/sbin/mysqld: Table ‘./mybacc_wordpress/wp_options’ is marked as crashed and last (automatic?) repair failed
2019-01-21T03:23:22.791382Z 15639 [ERROR] /usr/sbin/mysqld: Table ‘./mybacc_wordpress/wp_options’ is marked as crashed and last (automatic?) repair failed
2019-01-21T03:23:22.791579Z 15639 [ERROR] /usr/sbin/mysqld: Table ‘./mybacc_wordpress/wp_options’ is marked as crashed and last (automatic?) repair failed
2019-01-21T03:23:22.791753Z 15639 [ERROR] /usr/sbin/mysqld: Table ‘./mybacc_wordpress/wp_options’ is marked as crashed and last (automatic?) repair failed

参考:https://stackoverflow.com/questions/8843776/mysql-table-is-marked-as-crashed-and-last-automatic-repair-failed

 

server上用mysql 连接server

repair table wp_options' <table_name>;

image

刷新网站,搞定。

myodbc 连接问题

通过myodbc无法链接至MySQL的错误:
Client does not support authentication protocol requested
by server; consider upgrading MySQL client
官方的说法是
MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients. …..

网上的解决办法:

参考:http://www.cnblogs.com/yongzhi/articles/1360444.html

试验后,发现:

安装的myodbc版本3.51-07

更新到3.51-11,问题解决,不需要其他设置。

access 用myodbc 访问mysql乱码问题

要把access的数据导入的mysql的方法,要么用专门的工具,如db2mysql,或者,就是连接两者,然后用sql语句操作。

ms access 连接mysql数据库的方法:

1.安装myodbc,3.51即可

2.在access中,使用外部链接表,把mysql数据表连接到access中,这样,mysql的表就跟access本身的表格一样处理。

中间,就是中文乱码的问题,

网上的解决办法都是:MYSQL ODBC 乱码的解决方法

大概就是在mysql的odbc连接选项中,在数据源配置项 Initial Statement 中填入 SET CHARACTER SET GBK

这种方法,显示的时候没有问题,中文能正常显示,但是,当你插入中文数据到mysql中时,照样是乱码。

其实,在代码中,访问mysql时,处理这种情况,就是在执行sql语句前,执行 set names GB2312

设置连接过程中的字符集。

但是,直接在access的sql模式中执行的话,会显示因为不是select ,update等sql语句而失败。

解决办法:就是把之前的陪着数据源的选项中的set character  set,直接改成 set names GB2312,即可。

参考:http://bugs.mysql.com/bug.php?id=3348

用ADO连接MYSQL的连接字符串

How to set up the dbGo (ADO) ConnectionString for mySQL database

From Zarko Gajic,

If your database choice is mySQL and you are using dbGO (ADO) components, over mySQL ODBC 3.51 driver or MySQL Connector/ODBC 5.0, this is how your TADOConnection’s ConnectionString property should look:

  • When using “ODBC 3.51 LOCAL database“:

    ‘DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=myDatabase; USER=myUsername; PASSWORD=myPassword;OPTION=3;’

  • When using “ODBC 3.51 REMOTE database“:

    ‘DRIVER={MySQL ODBC 3.51 Driver}; SERVER=data.domain.com; PORT=3306; DATABASE=myDatabase; USER=myUsername; PASSWORD=myPassword; OPTION=3;’

  • When using “ODBC 5.0 LOCAL database“:

    ‘DRIVER={MySQL Connector/ODBC v5}; SERVER=localhost; DATABASE=myDatabase; UID=myUsername; PASSWORD=myPassword;OPTION=3;’

  • When using “ODBC 5.0 REMOTE database“:

    ‘DRIVER={MySQL Connector/ODBC v5}; SERVER=data.domain.com; PORT=3306; DATABASE=myDatabase; UID=myUsername; PASSWORD=myPassword;OPTION=3;’

Note: “data.domain.com” is the name of the data server, “myDatabase” is the name of the database, “myUsername” is the name of the user, “myPassword” is the password for “myUsername”

delphi中使用ado连接mysql乱码解决

delphi中,使用ado连接mysql,adoconnection的providor 设为:MSDASQL.1,可以先用系统数据源连接,然后在程序里面用连接字符串。

 

查询后,发现,listbox里面显示中文乱码

image

参考http://bbs.mysql.cn/viewthread.php?tid=364&extra=page%3D1%26amp%3Bfilter%3Ddigest

发现,可以执行以下语句

SET NAMES ‘CHARSETNAME’

用来设置客户端的字符集,例如:”SET NAMES ‘GB2312′”,可设置客户端的字符集为gb2312 。(UCS2暂时不可用)

在连接上数据库后,上面的语句以sql语句执行,即可。

执行后,乱码解决

image

mysql 安装的几个问题及解决

昨天装的mysql,因为没有时间,几个问题也没有解决。因为原先有安装旧版本的rpm包,只卸载了server包,再,原来的数据及配置仍在,日志如下:

1227 16:42:59 InnoDB: Starting shutdown…

041227 16:43:00 InnoDB: Shutdown completed; log sequence number 0 43634

041227 16:43:00 [Note] /usr/libexec/mysqld: Shutdown complete

041227 16:43:00 mysqld ended

041228 13:30:17 mysqld started

041228 13:30:18 InnoDB: Started; log sequence number 0 43634

041228 13:30:18 [Warning] mysql.user table is not updated to new password format ; Disabling new password usage until mysql_fix_privilege_tables is run

041228 13:30:18 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/time_zone _leap_second.frm’ (errno: 13)

041228 13:30:18 [Warning] Can’t open and lock time zone table: Can’t find file: ‘./mysql/time_zone_leap_second.frm’ (errno: 13) trying to live without them

/usr/libexec/mysqld: ready for connections.

Version: ‘4.1.7’ socket: ‘/tmp/mysql.sock’ port: 3306 Source distribution

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/help_cate gory.frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/help_keyw ord.frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/help_rela tion.frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/help_topi c.frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/time_zone .frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/time_zone _leap_second.frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/time_zone _name.frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/time_zone _transition.frm’ (errno: 13)

041228 13:31:30 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/time_zone _transition_type.frm’ (errno: 13)

041228 13:31:59 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/time_zone .frm’ (errno: 13)

多次运行mysql_install_db及mysql_create_system_database都没有解决。今天一气之下,make uninstall了。并且,删除原来的配置文件/etc/my.cnf,以及数据目录/var/lib/mysql/,重新make install。运行了mysql_install_db及mysql_create_system_database之后,出现041228 17:53:31 InnoDB: Started; log sequence number 0 43634

041228 17:53:31 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/host.frm’ (errno: 13)041228 17:53:31 [ERROR] Fatal error: Can’t open privilege tables: Can’t find file: ‘./mysql/host.frm’ (errno: 13)

041228 17:53:31 mysqld ended

的错误,查看数据目录存在表格host.frm,发现属主为root且其他人没有读权限,chown mysql.mysql host.frm后,该错误消除,但出现类似的错误,把该目录全部chown 之后,问题解决。