11、centos6虚拟机简单安装mysql5.7

    xiaoxiao2021-03-25  138

    继上一遍安装虚拟机后,再安装一台搭建mysql服务

    1、mysql官网下载教程  【http://jingyan.baidu.com/article/ceb9fb10b77bba8cad2ba09a.html】

    官网地址:https://dev.mysql.com/downloads/    下载最新的mysql-5.7.17-linux-glibc2.5-x86_64.tar 【官网】 一些国内镜像: http://ftp.plusline.de/mysql/Downloads/MySQL-5.5/

    http://mirrors.sohu.com/mysql/

    进入下载页面:有其他版本的选择,

    2、官网的文旦中写着镜像地址:https://dev.mysql.com/doc/refman/5.7/en/getting-mysql.html  http://dev.mysql.com/downloads/mirrors.html【无国内】 3、官网的文旦:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html#binary-installation-layout mysql5.7的安装教程: 我按照另外一遍文旦安装 mysql-5.7.17-linux-glibc2.5-x86_64.tar  【http://blog.csdn.net/bao19901210/article/details/51917641】 ①groupadd mysql ②useradd -r -g mysql mysql ③解压二进制文件到自己定义的/apps/mysql5.7/目录下:tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar ④创建数据库存放文件夹: mkdir mysqlData   创建数据库缓存sock文件夹: mkdir tmp 

     

    ⑤更改mysql5.7目录所属的组和用户。更改权限  chown -R mysql .  chgrp -R mysql .   ⑥进入/apps/mysql5.7/mysql-5.7.17-linux-glibc2.5-x86_64 目录下: 执行mysql_install_db脚本,对mysql中的data目录进行初始化并创建一些系统表格。【最后一行是root初始化密码】 bin/mysqld --initialize --user=mysql --basedir=/apps/mysql5.7/mysql-5.7.17-linux-glibc2.5-x86_64 --datadir=/apps/mysql5.7/mysqlData 【 --user    启动mysql的用户  --basedir  mysql安装目录  --datadir  mysql数据仓库目录】 ⑦ 将mysql5.7/目录下除了data/目录的所有文件,改回root用户所有,mysql用户只需作为mysql/data/目录下所有文件的所有者。 chown -R root .   chown -R mysql data    【这里如果有必要,就给每给文件夹都附上读写权限:  chmod -R 777 /apps/mysql5.7/ (我的这里全部附上读写权限)】 ⑧复制配置文件 cp support-files/my-default.cnf /etc/my.cnf   ⑨mysql5.7配置文件需要修改my.cnf关键配置 [mysqld]  【必须要在这个标识后面配置】 basedir = /apps/mysql5.7/mysql-5.7.17-linux-glibc2.5-x86_64  【修改为自己的】 datadir = /apps/mysql5.7/mysqlData   【修改为自己的】   port = 3307   socket = /apps/mysql5.7/tmp/mysql.sock  【修改为自己的,这个tmp文件夹需要自己创建,创建后要赋予mysql权限,chown -R mysql:mysql tmp 】   sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES  【默认有】 ⑩、将mysqld服务加入开机自启动项。 cp mysql.server /etc/init.d/mysql  chmod +x /etc/init.d/mysql ⑪、 把mysql注册为开机启动的服务  chkconfig --add mysql  ⑫、 查看是否添加成功  chkconfig --list mysql  ⑬、 mysql服务的开启和关闭【这几种方法都试一遍,发现除了bin/mysqld_safe& 可以启动,其他两个报错】  /etc/init.d/mysql start   或者   serivce mysql start  或者  bin/mysqld_safe&    /etc/init.d/mysql stop    或者   service mysql stop   或者  bin/mysqladmin -uroot -p         ⑭、解决启动报错的问题 Starting MySQL.2017-03-07T09:36:01.819114Z mysqld_safe The file /usr/local/mysql/bin/mysqld does not exist or is not executable. Please cd to the mysql installation directory and restart this script from there as follows: ./bin/mysqld_safe& See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information ERROR! The server quit without updating PID file (/apps/mysql5.7/mysqlData/centos68x64-mysql.pid). 报错:解决方法【url】http://www.cnblogs.com/moss_tan_jun/p/6080058.html mkdir -p /usr/local/mysql/bin   ln -s /apps/mysql5.7/mysql-5.7.17-linux-glibc2.5-x86_64/bin/mysqld /usr/local/mysql/bin/mysqld 为什么要创建 /usr/local/mysql/bin/mysqld 这个启动软连接?暂时不清楚。【需看官网文旦】        ⑮、启动成功、登录mysql服务前建立软链接【作用?】: ln -s /apps/mysql5.7/mysql-5.7.17-linux-glibc2.5-x86_64/bin/mysql  /usr/local/bin ln -s /apps/mysql5.7/mysql-5.7.17-linux-glibc2.5-x86_64/bin/mysqladmin  /usr/local/bin

    ln -s /apps/mysql5.7/mysql-5.7.17-linux-glibc2.5-x86_64/bin/mysqld_safe  /usr/local/bin

    登陆后报错:【解决问题url:http://blog.csdn.net/ixidof/article/details/5958904/  (只需添加软链接)】 ln -s /apps/mysql5.7/tmp/mysql.sock /tmp/mysql.sock 再次登录mysql服务成功: 修改密码: alter user 'root'@'localhost' identified by '123123'; ⑯远程连接不上 2003错误,按照url配置【http://blog.csdn.net/sun614345456/article/details/53672150】

    继续报错1045,继续排查【http://blog.csdn.net/yang382197207/article/details/18217429】

    发现password是要设置的【防火墙关了、user表有数据,网上说的是ip地址被屏蔽,配置文件中没有,所以猜想配置密码错误】, 重新设置权限: mysql -uroot -p123123 use mysql; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; FLUSH PRIVILEGES; 

    service mysqld restart

    最后登录成功。
    转载请注明原文地址: https://ju.6miu.com/read-6993.html

    最新回复(0)