Linux不用安装mysql到系统盘_linux安装mysql 5.6.33

执行命令:ps -ef|grep mysql 看到mysql服务说明启动成功。

7.修改mysql的root用户密码,root初始密码为空的:

执行命令:./bin/mysqladmin -u rootpassword '密码'

如果报错:

/usr/bin/mysqladmin: connect toserver at 'localhost' failed

error: 'Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock' (2)'

Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock'exists!

(1)先停止服务:service mysql stop

(2)修改/etc/my.conf:[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

If there is not currently asection called [client], add one at the bottom of the file and copy the socket=line under the [mysqld] section such as:

[client]

socket=/var/lib/mysql/mysql.sock

(3)执行/usr/local/mysql/bin/mysqld_safe& service mysql start

(4)无密码root帐号登陆

/usr/bin/mysql -uroot -p 【注释,在下面的要求你输入密码的时候,你不用管,直接回车键一敲就过去了】

Enter password:

Welcome to the MySQL monitor. Commandsend with ; or \g.

…………

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

mysql>use mysql;

Database changed

(5) 手动update修改密码

mysql> update user setpassword=password("新密码") where user='root' andhost='localhost';

Query OK, 1 row affected (0.00sec)

Rows matched: 1 Changed: 1 Warnings:0

mysql> flush privileges;

Query OK, 0 rows affected (0.00sec)

mysql> quit

Bye

8.正常重新启动mysql服务登录 mysql -uroot -p

9.把mysql客户端放到默认路径:

ln -s/usr/local/mysql/bin/mysql /usr/local/bin/mysql

注意:建议使用软链过去,不要直接包文件复制,便于系统安装多个版本的mysql

服务器症状: 今天网站web页面提交内容到数据库,发现出错了,一直提交不了,数找了下原因,发现数据写不进去!第一反应,重启mysql数据库,一直执行中,停止不了也启动不了,直觉告诉我磁盘满了 !用df命令查了下,果然磁盘满了,因为当时分区采用系统默认,不知道为什么不能自动扩容!以后在处理这个问题!如图所示:

[root@rekfan ~]# df 文件系统                 1K-块      已用      可用 已用% 挂载点 /dev/mapper/vg_rekfan-lv_root 51606140  47734848   1249852  100%      / tmpfs                  1953396        88   1953308   1%           /dev/shm /dev/sda1               495844     37062    433182   8%        /boot /dev/mapper/vg_rekfan-lv_home 229694676    191796 217835016   1%       /home [root@rekfan ~]#

删除了些没用的日志后,重新启动数据库还是出错。http://blog.rekfan.com/?p=186

[root@rekfan mysql]# service mysql restart MySQL server PID file could not be found![失败] Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/rekfan.pid).[失败]

google了下 ,问题可能的原因有多种,具体什么原因最好的办法是先查看下错误日志:

1.可能是/usr/local/mysql/data/rekfan.pid文件没有写的权限解决方法 :给予权限,执行 “chown-R mysql:mysql/var/data” “chmod -R 755 /usr/local/mysql/data”  然后重新启动mysqld!

2.可能进程里已经存在mysql进程解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9  进程号”杀死,然后重新启动mysqld!

3.可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。 解决方法:去mysql的数据目录/data看看,如果存在mysql-bin.index,就赶快把它删除掉吧,它就是罪魁祸首了。本人就是使用第三条方法解决的 !http://blog.rekfan.com/?p=186

4.mysql在启动时没有指定配置文件时会使用/etc/my.cnf配置文件,请打开这个文件查看在[mysqld]节下有没有指定数据目录(datadir)。 解决方法:请在[mysqld]下设置这一行:datadir = /usr/local/mysql/data

5.skip-federated字段问题 解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧。

6.错误日志目录不存在 解决方法:使用“chown” “chmod”命令赋予mysql所有者及权限

7.selinux惹的祸,如果是centos系统,默认会开启selinux 解决方法:关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器试试。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值