Centos7安装mysql-5.7.11上海时时乐走势图官网

12. 添加MySQL服务

Centos7安装mysql-5.7.11

先是次在Centos安装MySQL,境遇比非常多主题材料,进度中部分主题材料分享下,有欠缺的地点,请指教~~

一.环境
1.Centos7 全安装(一些骨干的软件都设置了)
2.mysql版本5.7.11

二.安装mySql准备
1.依赖
# yum install -y gcc-c make cmake bison bison-devel ncurses-devel libaio-devel perl
# yum install -y perl-Data-Dumper

2.mysql客商以至用户组
翻开是或不是业已创办了:
# cat /etc/passwd | grep mysql
# cat /etc/group | grep mysql

从没开创则新建mysql客户以致客户组:
# groupadd mysql
# useradd -r -g mysql mysql

3.解压源码包
# tar -zxv -f mysql-5.7.11.tar.gz

4.分明硬盘空间,mysql大概要求2G的设置空间
# df -h

三.安装mysql
1.cmake安装
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
  -DWITH_MYISAM_STORAGE_ENGINE=1
  -DWITH_INNOBASE_STORAGE_ENGINE=1
  -DWITH_MEMORY_STORAGE_ENGINE=1
  -DWITH_READLINE=1
  -DENABLED_LOCAL_INFILE=1
  -DMYSQL_DATADIR=/usr/local/mysql/data
  -DMYSQL_USER=mysql
  -DMYSQL_TCP_PORT=3306
-DDOWNLOAD_BOOST=1
-DWITH_BOOST=/usr/share/doc/boost-1.53.0

报错:CMake Error at cmake/boost.cmake:81 (MESSAGE): You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
缓慢解决:检查是还是不是安装了boost
一经设置了,在cmake增加 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=boost的安装目录(那时,先下载boost_1_59_0.tar.gz,并把boost_1_59_0.tar.gz复制到boost的安装目录相比较好,centos安装下载的话,恐怕会报"Timeout was reached"错误)
假如没设置,
# yum search boost
# yum install -y boost.x86_64

增添了boost之后,再次运维
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
  -DWITH_MYISAM_STORAGE_ENGINE=1
  -DWITH_INNOBASE_STORAGE_ENGINE=1
  -DWITH_MEMORY_STORAGE_ENGINE=1
  -DWITH_READLINE=1
  -DENABLED_LOCAL_INFILE=1
  -DMYSQL_DATADIR=/usr/local/mysql/data
  -DMYSQL_USER=mysql
  -DMYSQL_TCP_PORT=3306
-DDOWNLOAD_BOOST=1
-DWITH_BOOST=/usr/share/doc/boost-1.53.0

2.编写制定并设置
2.1 编译(时间会比较久,大约半个时辰左右)
# make

2.2 安装
# make install

2.3 修改配置文件/etc/my.cnf
[mysqld]
#basedir是新扩大进去的,原本未有
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in

[mysqld_safe]
#其一目录很入眼,当运维mysql报错开上下班时间,错误日志就要这里个文件下
log-error=/usr/local/mysql/logs/mysql.log
#布局localhost.localdomain.pid路线,以防报错Starting MySQL. EPAJEROROENVISION! The server quit without updating PID file (/usr/local/mysql/localhost.localdomain.pid).
pid-file=/usr/local/mysql/localhost.localdomain.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

2.4 修改目录具备者
# chown -R mysql:mysql /usr/local/mysql

2.5 添加MySQL服务
在mysql安装目录下
# cp /support-files/mysql.server /etc/init.d/mysql

四.启动mysql
1.启动mysql服务
# service mysql start

2.启动mysql
2.1 登陆(在mysql安装目录的bin下)
# mysql -uroot -p

报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决:使用mysql指定的mysql.sock目录
# mysql -uroot -p -S /usr/local/mysql/mysql.sock

2.2 修改密码
mysql> update user set authentication_string=PASSWORD("vst123456") where user='root';

五.会见过的主题素材
1.问题:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
陈述:在mysql第壹回登陆蒙受
化解:在 /etc/my.cnf 的 mysqld上边增多 skip-grant-tables
如下,省掉了解说:
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock

symbolic-links=0

skip-grant-tables

[mysqld_safe]
log-error=/usr/local/mysql/logs/mysql.log
pid-file=/usr/local/mysql/localhost.localdomain.pid

!includedir /etc/my.cnf.d

2.问题:(1)ERROR! MySQL server PID file could not be found!
Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid)
(2)ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/mysql.sock'
陈说:在mysql第壹次登入碰到
化解:以前在一贯不配置 /etc/my.cnf 的 socket 和 pid-file 以前平日遇到,因为那三个参数原先是有暗中同意值的,并不是编写翻译安装时的内定
路子,因为在陈设了点名路径之后,再也尚无境遇过
如下,省掉了疏解:
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock

symbolic-links=0

skip-grant-tables

[mysqld_safe]
log-error=/usr/local/mysql/logs/mysql.log
pid-file=/usr/local/mysql/localhost.localdomain.pid

!includedir /etc/my.cnf.d

3.问题:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
陈说:在mysql第二回登入修改了密码后,第壹遍登入时境遇
缓慢解决:mysql> alter user 'root'@'localhost' identified by 'rootadmin';(rootadmin登入密码)

4.问题:ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
陈述:在修改密码时,未有设置过期状态为 N
解决:
率先步:修改 /etc/my.cnf 的 mysqld下边添加 skip-grant-tables ,一碗水端平启mysql
第二步:登陆mysql,并再次设置密码和过期状态
mysql> update user set authentication_string=PASSWORD("vst123456"),password_expired = 'N' where user='root';
其三步:修改 /etc/my.cnf 的 mysqld上面删除 skip-grant-tables ,同仁一视启mysql

5.问题:host 192.168.*.* is not allowed to connect to this mysql server
陈说:使用客商端连接mysql时报错
解决:
(1)端口原因,没盛放3306端口
# firewall-cmd --state //查看firewall是或不是运营
# firewall-cmd --zone=public --add-port=3306/tcp --permanent //增多开放端口
# firewall-cmd --reload //重启防火墙

(2)帐号不一样意从远程登入
登录mysql
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>flush privileges;
mysql>select host, user from user;

六.结束

第贰次在Centos安装MySQL,碰到重重主题材料,进度中有些标题分享下,有不足的地点,请指教~~ 一.环境 1.Centos7 全安装(一些...

  1. 始建MySQL安装目录和多少目录

    1 mkdir /usr/local/mysql 2 mkdir /usr/local/mysql/data

1 groupadd mysql
2 useradd -r -g mysql mysql
tar -zxv -f mysql-5.7.15.tar.gz
  1. cmake安装MySQL

    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=/usr/local/boost/boost_1_59_0.tar.gz

 

展现运转成功:Starting MySQL....... SUCCESS!

  1. 开启MySQL

    /usr/local/mysql/bin/mysql -uroot -p

  2. 完成!

 上海时时乐走势图官网 1

2. 去MySQL官方网站下载MySQL源码安装包,注意,必要求选拔下图的源代码版,不然cmake时会报错:

5. 自家把源码包放在了/tmp目录下,解压缩MySQL

 

 

 

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  1. 设置进度会不停一段时间,耐心等待。

    make && make install

 

  1. 安装完结以后修改/etc/my.cnf

    vim /etc/my.cnf

    [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock

    symbolic-links=0

    skip-grant-tables

    [mysqld_safe] log-error=/usr/local/mysql/logs/mysql.log pid-file=/usr/local/mysql/localhost.localdomain.pid

    !includedir /etc/my.cnf.d    

    mkdir /usr/local/mysql/logs

mkdir /usr/local/boost
cp /tmp/boost_1_59_0.tar.gz /usr/local/boost/

7. 创造boost文件夹并复制boost文件到这些目录中,否则cmake会报错,本示例中使用的是boost_1_59_0.tar.gz

  1. 启动MySQL

    service mysql start

  1. 设置境况:CentOS 7 62人    MySQL 5.7

 

未曾开创则新建mysql客商以致顾客组:

  1. 修改MySQL目录全部者

    chown -R mysql:mysql /usr/local/mysql

  1. 创制MySQL客户和客户组
    先查看是或不是已经创办:

    cat /etc/passwd | grep mysql cat /etc/group | grep mysql

 

 

 

 

 

  1. 前期安装信任软件:

    yum install -y gcc-c make cmake bison bison-devel ncurses-devel libaio-devel perl perl-Data-Dumper

本文由上海时时乐走势图发布于上海时时乐走势图官网,转载请注明出处:Centos7安装mysql-5.7.11上海时时乐走势图官网

您可能还会对下面的文章感兴趣: