Centos 安装Mysqld5.7.17

最近安装一个高版本的MYSQL,与以前的版本小异,网上的有些文章不知云里雾里,看官网文档是最好的,特做记录。

Centos7的源已经没有mysql安装包, 需要从mysql官网下载安装包
 
 
2. 各种社区版本的下载
 
3. yum下载地址
   下载Mysql的yum安装源文件,安装后
 
  
 
   rpm -ivh mysql57-community-release-el7-11.noarch.rpm
    yum install mysql-community-server
 
 
4. 要么直接下载rpm安装
 

Index of /232905/yum

   Name                              Last modified        Size  

   
   
[DIR] Parent Directory 21-Sep-2017 15:22 1k [DIR] mysql-5.5-community/ 21-Sep-2017 08:02 1k [DIR] mysql-5.6-community/ 21-Sep-2017 08:04 1k [DIR] mysql-5.7-community/ 21-Sep-2017 08:04 1k [DIR] mysql-8.0-community/ 21-Sep-2017 15:22 1k [DIR] mysql-cluster-7.5-community/ 21-Sep-2017 08:01 1k [DIR] mysql-cluster-7.6-community/ 21-Sep-2017 08:03 1k [DIR] mysql-community/ 21-Sep-2017 08:02 1k [DIR] mysql-connectors-community/ 21-Sep-2017 08:02 1k [DIR] mysql-tools-community/ 21-Sep-2017 08:04 1k [DIR] mysql-tools-preview/ 21-Sep-2017 03:38 1k

 
 
依赖包
====================================================================================================================================
Installing:
 mysql-community-libs                                                x86_64                                         5.7.19-1.el7                                            mysql57-community                                         2.1 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-libs-compat                                         x86_64                                         5.7.19-1.el7                                            mysql57-community                                         2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-server                                              x86_64                                         5.7.19-1.el7                                            mysql57-community                                         164 M
Installing for dependencies:
 mysql-community-client                                              x86_64                                         5.7.19-1.el7                                            mysql57-community                                          24 M
 mysql-community-common                                              x86_64                                         5.7.19-1.el7                                            mysql57-community                                         272 k
 
Transaction Summary
 
 
直接下载链接
 
 
 
 
注意:Mysql5.7.6 前半部与5.7.6后的版本是有区别的,看官网文档!
 
Linux数据库初始化文档参考
 
Root缺省用户
 
用户管理文档
 
用户管理
 
 
 
配置mysql文件
 
[root@localhost data]# more  /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
 
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
 
bind-address=0.0.0.0
 
#datadir=/var/lib/mysql
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
 
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
 
[client]
socket=/var/lib/mysql/mysql.sock
 
#skip-grant-tables
 
 
 
查看/var目录
[root@localhost ~]# cd /var/run/
[root@localhost run]# ls -al | grep mysql
drwxr-xr-x.  2 mysql mysql   40 Dec 28 10:09 mysqld
[root@localhost run]#
 
 
查看mysql系统用户
vi /etc/passwd
mysql:x:996:1001::/home/mysql:/bin/bash
 
查看mysql日志
/var/log/mysqld.log
 
 
初始化数据库
 
mysqld --user=mysql --basedir=/usr/local/mysq --datadir=/data/mysql  --initialize-insecure
 
查看数据文件
[root@localhost mysql]# ls -al /data/mysql/
total 110596
drwxr-xr-x. 2 mysql mysql       77 Dec 28 10:48 .
drwxr-xr-x. 3 root  root        18 Dec 28 10:32 ..
-rw-r-----. 1 mysql mysql      215 Dec 28 10:48 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Dec 28 10:48 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Dec 28 10:48 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Dec 28 10:48 ib_logfile1
 
 
设置root密码和授权
 
mysql -u root --skip-password
 
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxx';
CREATE USER 'root'@'%' IDENTIFIED BY 'xxxx';
 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
 
[root@localhost data]# mysql -u root -pxxxx
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.17 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2016, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed

mysql> desc user;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field                  | Type                              | Null | Key | Default               | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host                   | char(60)                          | NO   | PRI |                       |       |
| User                   | char(32)                          | NO   | PRI |                       |       |
| Select_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Insert_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Update_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Delete_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Create_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Drop_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Reload_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Shutdown_priv          | enum('N','Y')                     | NO   |     | N                     |       |
| Process_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| File_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Grant_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| References_priv        | enum('N','Y')                     | NO   |     | N                     |       |
| Index_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Show_db_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Super_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tmp_table_priv  | enum('N','Y')                     | NO   |     | N                     |       |
| Lock_tables_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Execute_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_slave_priv        | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_client_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Create_view_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Show_view_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Create_routine_priv    | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_routine_priv     | enum('N','Y')                     | NO   |     | N                     |       |
| Create_user_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Event_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Trigger_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tablespace_priv | enum('N','Y')                     | NO   |     | N                     |       |
| ssl_type               | enum('','ANY','X509','SPECIFIED') | NO   |     |                       |       |
| ssl_cipher             | blob                              | NO   |     | NULL                  |       |
| x509_issuer            | blob                              | NO   |     | NULL                  |       |
| x509_subject           | blob                              | NO   |     | NULL                  |       |
| max_questions          | int(11) unsigned                  | NO   |     | 0                     |       |
| max_updates            | int(11) unsigned                  | NO   |     | 0                     |       |
| max_connections        | int(11) unsigned                  | NO   |     | 0                     |       |
| max_user_connections   | int(11) unsigned                  | NO   |     | 0                     |       |
| plugin                 | char(64)                          | NO   |     | mysql_native_password |       |
| authentication_string  | text                              | YES  |     | NULL                  |       |
| password_expired       | enum('N','Y')                     | NO   |     | N                     |       |
| password_last_changed  | timestamp                         | YES  |     | NULL                  |       |
| password_lifetime      | smallint(5) unsigned              | YES  |     | NULL                  |       |
| account_locked         | enum('N','Y')                     | NO   |     | N                     |       |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
45 rows in set (0.01 sec)
 
mysql> select Host,User from user;
+-----------+-----------+
| Host      | User      |
+-----------+-----------+
| localhost | mysql.sys |
| localhost | root      |
+-----------+-----------+
2 rows in set (0.00 sec)
 
mysql>
 
 
查看mysql端口
 
[root@localhost etc]# netstat -ntpl | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      24088/mysqld
 
 
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl disable iptables.service
 
 
一些可能的问题提示

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、付费专栏及课程。

余额充值