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 登录显示

ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: NO)

解决办法:

MysqL配置文件/etc/my.conf中的[MysqLd]中加入:

pid-file=/var/lib/MysqL/MysqLid.pid

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



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

在linux命令行界面输入:

mys1qladmin-urootpassword'123'

再次用root身份登录

mys1ql-uroot-p

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

[root@localhostsupport-files]#/etc/init.d/MysqLdstart
StartingMysqL...TheserverquitwithoutupdatingPIDfile[失败]ication/MysqL/data/localhost.localdomain.pid).

查看有关MysqL的进程

[root@localhostsupport-files]#ps-ef|grepMysqL

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@localhostsupport-files]#kill-912821
[root@localhostsupport-files]#kill-912949

再次打开MysqL

[root@localhostsupport-files]#/etc/init.d/MysqLdstart

Starting MysqL.. [确定]

[root@localhostsupport-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

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native