linux安装mysql 5.6.33

    xiaoxiao2021-04-16  34

    .到MySQL官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (glibc 2.5) (x86, 64-bit),下载后文件名:mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz 2.解压64位安装包: 进入安装包所在目录,执行命令:tar xzvfmysql-5.6.33-linux-glibc2.5-x86_64.tar.gz 3.复制解压后的mysql目录到系统的本地软件目录: 执行命令:cp mysql-5.6.33-linux-glibc2.5-x86_64/usr/local/mysql -r 注意:目录结尾不要加/ 4.添加系统mysql组和mysql用户: 执行命令:groupadd mysql和useradd -r -g mysql mysql 5.安装数据库: 进入安装mysql软件目录:执行命令 cd/usr/local/mysql 修改当前目录拥有者为mysql用户:执行命令chown-R mysql:mysql ./ 安装数据库:执行命令./scripts/mysql_install_db--user=mysql 修改当前目录拥有者为root用户:执行命令chown-R root:root ./ 修改当前data目录拥有者为mysql用户:执行命令chown -R mysql:mysql data 到此数据库安装完毕

    6.启动mysql服务和添加开机启动mysql服务: 添加开机启动:执行命令cp support-files/mysql.server /etc/init.d/mysql,把启动脚本放到开机初始化目录 chmod +x /etc/init.d/mysql    赋予可执行权限

    chkconfig --add mysql        添加服务 chkconfig --list            显示服务列表 如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则键入 chkconfig --level 345 mysql on

    启动mysql服务:执行命令service mysql start

    执行命令: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后存盘退出重启机器试试。

    转载请注明原文地址: https://ju.6miu.com/read-673055.html

    最新回复(0)