分享、学习、提高
Thank you for reading...
2008/01/24 10:56
Tags:
一个Discuz论坛,原来架在windows下,用的是GBK编码,MYSQL版本是5.0的。
现在需要转移到Linux下,我本来建议用mysqldump导出的方法,但同事希望直接用data目录下的数据库目录。

那就先用移目录的方式试下,在新服务器创建数据库,然后将旧的目录移过来。

在mysql中,Select之类的都正常,但在网页程序中提示:Table 'cdb_posts' is read only

给数据库目录的所属用户和组改为mysql,并加上777的权限,还是一样提示。

程序中使用root连接,也是一样的提示。

想用myisamchk来检查一下,也提示read only。

最终在这里找到了解决方法:http://www.mysqltalk.org/re-the-table-is-read-only-vt154092.html
引用
I just encountered a similar problem on one of my production servers
this morning. (I'm still investigating the cause.) After doing a
quick bit of Google-searching, this solved my problem:

mysqladmin -u <username> -p flush-tables

By the way: All directories in /var/lib/mysql should have 700
permissions (owned my the mysql user) and everything within those
directories should be 660 (owned by the mysql user and mysql group).


运行flush-tables后,read only问题解决:)

然后发现数据结构和内容还是有问题,用myisamchk查错无效,后来用mysqldump导,不过也还是碰到了一大堆问题,由于要转的数据库挺大,化了很长时间,最终没有继续下去。
了解了一些知识点,记录一下:
就是mysql5导出的有default-charact的设置,mysql4不支持,需要加skip-opt参数,如:
mysqldump -uroot -p --default-character-set=gbk -skip-opt databse > hx.sql
参考文章:Mysql 数据库字符集转换

最后找了台mysql5的服务器,用mysqldump导出,mysql导入,一次成功!
发现用mysqldump导出一个表,300w多条记录,用了才4分多钟,每秒处理1w多记录,快啊!导入时,差不多用了十几分钟,每秒导入几千条也很快了:)
2007/12/11 21:36
Tags:
写给一个朋友用的,顺便也整理了一下,发上来。

windows下
cmd
cd c:\mysql\bin
C:\mysql\bin>mysql.exe -uroot -p
Linux下
/usr/local/mysql/bin/mysql -uroot -p
路径视安装目录而定。

直接回车(因为默认情况下root@localhost密码是空,否则要输root密码)

创建数据库
mysql> create database vista;
Query OK, 1 row affected (0.02 sec)

增加用户(创建用户名为vista,主机为localhost的用户)
mysql> Grant All on vista.* to vista@localhost;
Query OK, 0 rows affected (0.11 sec)

设置用户密码,也可以用此命令修改用户密码
mysql> update mysql.user set password = password('密码') where user=
'vista' and host = 'localhost';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.14 sec)

退出MYSQL,完成
mysql> exit
2007/08/22 15:00
Tags: ,
提示:
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in /www/xxxx/lib.php on line 31
Connect to mysql failed:
Client does not support authentication protocol requested by server; consider upgrading MySQL client


查了一下,官方的说明:
引用

MySQL 5.0 uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older (pre-4.1) clients. If you upgrade the server from 4.0, attempts to connect to it with an older client may fail with the following message:

Client does not support authentication protocol requested
by server; consider upgrading MySQL client


解决方法是:
引用
Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function:
mysql> SET PASSWORD FOR  'some_user'@'some_host' = OLD_PASSWORD('newpwd');

Alternatively, use UPDATE and FLUSH PRIVILEGES:
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')    -> WHERE Host = 'some_host' AND User = 'some_user';mysql> FLUSH PRIVILEGES;

地址:http://dev.mysql.com/doc/refman/5.0/en/old-client.html


我建数据库用户时,使用了Grant All on db.* to hx identified by 'hxpass',这样密码是新的加密方式,解决的办法就是将密码重置为旧的(用OLD_PASSWORD加密的)密码。

中文参考资料:http://www.itlearner.com/article/2007/3759.shtml
2007/07/24 13:25
Tags:
运行正常的程序突然感觉很慢,在切换页面时还出现了一个这样的提示:
Error: Too many connections
Errno.: 1040

主要参考:http://www.itlearner.com/article/2007/3820.shtml
通过修改safe_mysqld源文件的方法来解决这个问题。

照文章所写的修改后,上传。

重启:
/bin/mysqladmin -u root -p shutdown
/bin/mysqld_safe --user=mysql &
居然提示:# -bash: ./mysqld_safe: 权限不够
给它权限:chmod 755 mysqld_safe
再启动,OK

另参考:http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html

UPDATE@@070827补充:
其实还有一种方法是直接修改启动参数,可能更方便些。最大连接数设置为500就行了,太大了服务器也受不了。
/usr/local/mysql/bin/mysqld_safe --max_connections=500 --max_connect_errors=50000 &


UPDATE@@081117补充:
上述设置后,有时还会碰到这种情况,可以使用如下命令重启MYSQL。不要用Kill结束掉mysql,很容易造成数据表损坏!
/usr/local/mysql/support-files/mysql.server restart
2007/07/09 19:10
Tags: ,
本机打了Win2003的SP2,在运行时,突然死机。

重启后,运行PHP程序,原来好好的,突然出现:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

看看sql语句,没啥不正确呀。
去phpmyadmin中运行一下,晕,提示:
#126 - Incorrect key file for table '.\mobile\mobile.MYI'; try to repair it

使用其的检查表(CHECK TABLE `mobile`),提示确实有错误,正准备用修复表(REPAIR TABLE `mobile`),突然提示:

#145 - Table '.\mobile\mobile' is marked as crashed and should be repaired

...直接表损坏了:(

网上搜索一下,说是使用这句。

myisamchk -c -r *.MYI


C:\MySQL\data>myisamchk -c -r *.MYI
myisamchk: error: 22 when opening MyISAM-table '*.MYI'

C:\MySQL\bin>myisamchk mobile.MYI
myisamchk: error: File 'mobile.MYI' doesn't exist

想想,可能是它找不到文件吧。
于是
C:\MySQL\data>myisamchk -c -r c:/mysql/data/mobile/mobile.MYI
- recovering (with sort) MyISAM-table 'c:/mysql/data/mobile/mobile.MYI'
Data records: 104424
- Fixing index 1
- Fixing index 2
- Fixing index 3
Data records: 104430

哈,恢复!
分页: 2/4 第一页 上页 1 2 3 4 下页 最后页 [ 显示模式: 摘要 | 列表 ]