centos下使用mysql,centos下使用mysql的一些问题和解决方法

【问题1】在centos6.8上使用yum直接安装MySQL,一切正常安装。启动mysql时显示:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

(1)、cp /usr/share/mysql/my-medium.cnf/ /etc/my.cnf(将默认的配置文件模板复制过去覆盖原有的配置文件);

(2)、/etc/init.d/mysqld status查看MySQL运行状态,显示正常;

(3)、解决办法:

vim /etc/my.conf  ,在[mysqld]下面加入一句话:

【现在直接输入mysql直接进入mysql命令窗口】

【问题2】不能用mysql -u root -p 登录,显示:

解决办法:

在mysql配置文件/etc/my.conf中的[mysqld]中加入:

pid-file=/var/lib/mysql/mysqlid.pid

原因:mysql 用户没有操作/var/run目录的权限,所以pid文件无法创建,导致登陆时无法建立 进程信息文件,登陆进程就无法开启,自然无法登陆。

【问题3】刚刚装好的mysql没有为root设置密码,直接输入mysql就可以登录,为root设置密码的方法:

在linux命令行界面输入:

mys1qladmin -u root password '123'

再次用root身份登录:

mys1ql -uroot -p

【问题4】之前装好一个mysql,但是由于忘记了root密码,于是把文件/application/mysql删除了,然后重新解压一个mysql文件到/application下,并按照步骤设好各种环境,但是打开mysql是还是会有问题,显示:

[root@localhost support-files]# /etc/init.d/mysqld start

Starting MySQL...The server quit without updating PID file [失败] ication/ mysql/ data/localhost. localdomain.pid).

查看有关mysql的进程

[root@localhost support-files]# ps -ef | grep mysql

root     12821     1  0 May15 ?        00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --datadir=/application/mysql/data --pid-file=/application/mysql/data/localhost.localdomain.pid

mysql    12949 12821  0 May15 ?        00:00:14 /application/mysql/bin/mysqld --basedir=/application/mysql --datadir=/application/mysql/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/application/mysql/data/localhost.localdomain.err --pid-file=/application/mysql/data/localhost.localdomain.pid --socket=/tmp/mysql.sock

root     18450 17925  0 10:10 pts/0    00:00:00 grep mysql

杀死这两个进程

[root@localhost support-files]# kill -9 12821

[root@localhost support-files]# kill -9 12949

再次打开mysql

[root@localhost support-files]# /etc/init.d/mysqld start

Starting MySQL..                                           [确定]

[root@localhost support-files]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit

Bye

【问题5】初始化数据库报错如下,执行

/application/mysql-5.6.36/scripts/mysql_install_db --datadir=/application/mysql-5.6.36/data/ --basedir=/application/mysql-5.6.36/ --user=mysql 时报以下错误:

-bash: /application/mysql-5.6.36/scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory

【解决办法】

yum -y install perl perl-devel

【问题6】在问题5的基础上,安装好了perl,再次执行初始化数据库命令

/application/mysql-5.6.36/scripts/mysql_install_db --datadir=/application/mysql-5.6.36/data/ --basedir=/application/mysql-5.6.36/ --user=mysql 时报以下错误:

FATAL ERROR: please install the following Perl modules before executing /application/mysql-5.6.36/scripts/mysql_install_db:

【解决办法】

yum install -y perl-Module-Install.noarch

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值