Centos7安装MySQL常见问题

本文档提供了CentOS7环境下MySQL安装过程中遇到的各种常见问题及其解决方案,包括但不限于服务启动失败、权限设置错误、配置文件缺失等,并给出了详细的解决步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CentOS7下安装MySQL数据库常见问题

1. ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
1. 检查MySql服务是否启动service mysql start
2. 检查MySQL-server是否安装成功,可以通过yum install MySQL-server-5.6.25-1.el7.x86_64.rpm重新安装

2. Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist
执行mysql_install_db --user=mysql

3. rpm安装mysql后/etc/目录下找不到my.cnf
1. whereis mysql查看mysql安装目录
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
2. cp /usr/share/mysql/my-default.cnf /etc/my.cnf

4. Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/hsf.pid).
1. 执行yum install -y perl-Module-Install.noarch
2. 执行mysql_install_db --user=mysql
3. 执行service mysql start就可以正常启动mysql了
4. use mysql
5. update user set password=password('root') where user='root';

5. ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
1. #/etc/init.d/mysql stop
2. #mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
3. # mysql -u root mysql
4. mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
5. #/etc/init.d/mysql restart

6. mysql在Linux表明大小写敏感问题
1. 编辑/etc/my.cnf在[mysqld]下插入lower_case_table_names=1
2. 修改完成后重启mysql服务
3. 通过show variables like '%case%',查看是否修改成功

7. MySQL不能远程连接Host is not allowed to connect to Host ‘10.72.35.8’ is not allowd to connect to this MySQL server
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’WITH GRANT OPTION;
FLUSH PRIVILEGES;

8. Caused by: java.sql.SQLException: Your password has expired. To log in you must change it using a client that supports expired passwords.
mysql5.6.25添加了密码过期机制
1. use mysql;
2. select host, user, password_expired from user;
3. update user set password_expired='N';

9. ERROR 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted
执行/etc/bin/mysql_upgrade,若出现无权访问需要再后面加上用户名和密码/etc/bin/mysql_upgrade -u root -p

10. ERROR 1010 (HY000): Error dropping database(can’t rmdir ‘./demo/’,errno:17)
执行find / -name demo
查找到mysql数据表存储位置,一般为 /var/lib/mysql/,直接删除该目录下的demo文件夹即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值