mysql常见问题
一:
1.查看mysql.sock地址是否是正确地址
我通过vim /etc/my.cnf,修改了[mysqld]选项下面的socket的值
socket=/usr/local/mysql/var/mysql.sock # 看看是否是mysql.sock的准确地址
2 为/tmp/mysql.sock 建立连接
ln -s /usr/local/mysql/varmysql.sock /tmp/mysql.sock
3.怎样保护“/tmp/mysql.sock ”不被删除
如果你有这个问题,事实上任何人可以删除MySQL通讯套接字“/tmp/mysql.sock”,在Unix的大多数版本上,你能通过为其设置sticky(t)位来保护你的“/tmp”文件系统。作为root登录并且做下列事情:
shell> chmod +t /tmp
这将保护你的“/tmp”文件系统使得文件仅能由他们的所有者或超级用户(root)删除。
你能执行ls -ld /tmp检查sticky位是否被设置,如果最后一位许可位是t,该位被设置了。
There are two main reasons for this error message to show:
1) The MySQL query you are trying to execute takes too long and the MySQL server times out.
The solution for this issue is to optimize your database for the queries which fail.
2) You have a crashed table in your database.
The solution in this case is to repair and optimize your database.
If a particular table crashes often and repairing/optimizing it does not help, this most probably means that the table's structure is not working properly with our MySQL server setup. In such cases the easiest way to fix a crashed MyISAM table for good is to change its database engine from MyISAM to InnoDB
6:mysqldump中--default-character-set参数理解:
7:太多的sleep进程
mysql -uroot -p***后登陆数据库,show proceelist;发现有太多的sleep进程,见附件!
原因:my.cnf中的wait_timeout和interactive_timeout 设置的太大!
my.cnf中的相关设置如下:
wait_timeout = 64800
interactive_timeout = 64800
将其修改为:
wait_timeout = 100
interactive_timeout = 100
问题即可正常!
8:有一段时间测试两个数据库间同步,#我们的环境比较特殊不适合用mysql master/slave,有几天测试使用rsync同步数据库下的表,发现使用rsync同步后,表经常损坏!
首先要修复表,修复的方法:
mysqlcheck -uroot –p*** --repair --extended mydb
9:有时候为了确保数据一致性,需要刷新mysql 缓存
方法见附件:
10:有时候也可以优化数据库:
mysqlcheck -u root -p**** --auto-repair --optimize --all-databases ##自动修复优化所有数据库
11:修改使得root远程登陆
:默认情况下,不允许root远程登陆,进行下面修改后就可以使得root远程登陆
12: shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
解决方法:
该错误表示 getcwd 命令无法定位到当前工作目录。一般来说是因为你 cd 到了某个目录之后 rm 了这个目录,这时去执行某些 service 脚本的时候就会报 getcwd 错误。只需要 cd 到任何一个实际存在的目录下在执行命令即可。
13:配置master/slave时遇到两个问题
13.1:
在slave上执行show master status;居然有显示,
原因:我在slave上也开启了log-bin文件!
解决方法:将该行注释掉,然后show master status就不会有结果显示了!
13.2:在配置master/slave时,
使用了grant all on test.* to ‘slaveuser’@’%’ identified by ‘slaveuser’; ##应该使用grant all on *.* to ‘slaveuser’@’%’ identified by ‘slaveuser’; 当然all的权限太大了,可以适当的调小!
导致了就算slaveuser的密码正确也会提示密码错误!
14:为了安装mysql5.5.X 编译cmake,结果出错,见附件
http://blog.chinaunix.net/uid-20776139-id-3301125.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?