linux上mysql启动失败问题解决
linux升级新的服务器后,mysql启动时遇到的各种问题记录
服务器升级迁移导致的mysql重启遇到的问题:
问题一:
linux启动mysql报错误如下:
"/lib64/libc.so.6: version `GLIBC_2.18' not found (required by /lib64/libstdc++.so.6)"
解决 "/lib64/libc.so.6: version `GLIBC_2.18' not found (required by /lib64/libstdc++.so.6)"
curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
tar zxf glibc-2.18.tar.gz
cd glibc-2.18/
mkdir build
cd build/ .
./configure --prefix=/usr
make -j2
make install
问题二:
1.使用命令查看mysql状态
service mysqld status
报错如下:
Unit mysqld.service could not be found.
解决MySQL问题-Unit mysqld.service could not be found.
[root@ldy ~]$ find / -name mysql.server
/usr/local/mysql-5.7/support-files/mysql.server
复制mysql.server到etc下的init.d文件下下:
[root@ldy ~]$ cp /usr/local/mysql-5.7/support-files/mysql.server /etc/init.d/mysqld
问题三:
mysql服务启动成功,,但是连接不上,解决如下:
1、登录
root@localhost:~# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
2、提示连接不到mysql.sock
解决方案一,定位问题:
1)、查找mysql.sock在哪里
root@localhost:~# find / -name mysql.sock
/usl/local/mysql/mysql.sock
2)、使用-S参数关联mysql.sock 再次尝试登录
root@localhost:~# mysql -u root -p -S /usl/local/mysql/mysql.sock
Enter password:
见到如下信息表示成功
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
说明是mysql.sock问题,使用方案二永久解决:
解决方案二,永久解决:
编辑my.cnf文件:
root@localhost:~# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# 加上下面的这段代码即可
[mysql]
socket=/tmp/mysql.sock
# 加上上面的这段代码即可
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
再次成功登录:
root@localhost:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
问题四:
内网可以访问数据库了,但是外网访问不了,这种情况一般是防火墙问题,
1、使用ping ip可是通
2、使用 telnet ip port
结果:telnet: connect to address ip: Connection timed out
解决方法:开通防火墙的端口:
1、查看防火墙是否已开放3306端口
firewall-cmd --query-port=3306/tcp
2、设置3306端口为永久开放
firewall-cmd --add-port=3306/tcp --permanent
3、查看firewalld状态,发现当前是dead状态,即防火墙未开启
systemctl status firewalld
(设置了新的端口记得先关闭,再重启)
4、关闭防火墙
systemctl stop firewalld
5、开启防火墙(设置了新的端口记得先关闭,再重启)
systemctl start firewalld
6、查看防火墙
systemctl status firewalld
7、查看已经开启的防火墙端口
firewall-cmd --list-all
更多推荐
所有评论(0)