centos7.3 安装 mysql-5.7.13

 系统环境:

[root@localhost ~]# cat /etc/RedHat-release 
CentOS release 6.7 (Final)
[root@localhost tools]# uname -a
Linux localhost 2.6.32-573.22.1.el6.x86_64 #1 SMP Wed Mar 23 03:35:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost tools]# 
软件准备:
[root@localhost tools]# pwd
/opt/tools
[root@localhost tools]# ll
total 674208
-rw-r--r-- 1 root root 639864682 Jul 22 17:47 mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
-rw-r--r-- 1 root root  50516207 May 25 12:01 mysql-5.7.13.tar.gz
[root@localhost tools]#
解压安装:
[root@localhost tools]# tar xf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz 
[root@localhost tools]# ll
total 674212
drwxr-xr-x 9 7161 wheel      4096 May 25 15:04 mysql-5.7.13-linux-glibc2.5-x86_64
-rw-r--r-- 1 root root  639864682 Jul 22 17:47 mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
-rw-r--r-- 1 root root  50516207 May 25 12:01 mysql-5.7.13.tar.gz
[root@localhost tools]# 
[root@localhost tools]# mv mysql-5.7.13-linux-glibc2.5-x86_64 /usr/local/mysql
[root@localhost tools]#
初始化操作(生成初始密码):
[root@localhost mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
2016-07-22T09:58:15.001776Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-07-22T09:58:15.062066Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-07-22T09:58:15.073009Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cebfb8a6-4ff2-11e6-8c8d-005056a01a07.
2016-07-22T09:58:15.074370Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-07-22T09:58:15.075736Z 1 [Note] A temporary password is generated for root@localhost: k_1ljzVh3<-,
[root@localhost mysql]#
PS: mysql5.7新特性:由上面可以看出, mysql_install_db 已经不再推荐使用了,建议改成 mysqld --initialize 完成实例初始化。
 
加入MySQL为系统服务:
[root@localhost mysql]# cp support-files/mysql.server  /etc/init.d/mysqld
[root@localhost mysql]# chkconfig mysqld on
[root@localhost mysql]# chkconfig --list|grep mysqld
mysqld          0:off  1:off  2:on    3:on    4:on    5:on    6:off
[root@localhost mysql]#chmod 755 /etc/init.d/mysqld
 
MySQL服务启动、重启、停止
[root@localhost mysql]# serivce mysqld start
[root@localhost mysql]# serivce mysqld stop
[root@localhost mysql]# serivce mysqld restart
[root@localhost mysql]# 
设置环境变量:
[root@localhost mysql]# vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
[root@localhost mysql]#
检查MySQL是否能开启

[root@localhost mysql]# cd /usr/local/mysql
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ./mysql.server start
Starting MySQL.. SUCCESS! 
若改用了, 则在启动服务时会出现如下错误:
# ./support-files/mysql.server start
./support-files/mysql.server: line 276: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
这时候我们需要修改/support-files/mysql.server文件的basedir和datadir目录路径为我们正确的mysql的basedir和datadir路径, 如下:
# vim support-files/mysql.server
--------------------------
...
basedir=/usr/local/mysql
datadir=/data/mysql/data
... 
--------------------------
# ./support-files/mysql.server start
Starting MySQL.. SUCCESS! 
创建配置文件
将默认生成的my.cnf备份
# mv /etc/my.cnf /etc/my.cnf.bak
[root@localhost support-files]# cp my-default.cnf  /etc/my.cnf
初始化mysql用户root的密码
先将mysql服务停止
# service mysqld stop
进入mysql安装目录, 执行:
# cd /usr/local/mysql
# ./bin/mysqld_safe --skip-grant-tables --skip-networking&
[1] 6225
[root@localhost mysql]# 151110 02:46:08 mysqld_safe Logging to '/data/mysql/data/localhost.localdomain.err'.
151110 02:46:08 mysqld_safe Starting mysqld daemon with databases from /data/mysql/data


另外打开一个终端(p.s. 如果是ssh连接登录的, 另外创建一个ssh连接即可), 执行操作如下:


# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.13 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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;
Database changed
mysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> update user set authentication_string = PASSWORD('123456') where user = 'root';
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 1


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


mysql> \s
mysql  Ver 14.14 Distrib 5.7.13, for linux-glibc2.5 (x86_64) using  EditLine wrapper


Connection id:          62
Current database:
Current user:          root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:        5.7.13-log MySQL Community Server (GPL)
Protocol version:      10
Connection:            Localhost via UNIX socket
Server characterset:    utf8
Db    characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /data/AEData/mysql/data/mysql.sock
Uptime:                46 min 54 sec


Threads: 6  Questions: 6846  Slow queries: 0  Opens: 257  Flush tables: 1  Open tables: 201  Queries per second avg: 2.432
--------------


mysql> 
到此, 设置完mysql用户root的密码且确保mysql编码集是utf8, 注意上面, 新版本的mysql.user表里的密码字段是authentication_string


MySQL远程授权
格式如下:
mysql> grant all [privileges] on db_name.table_name to 'username'@'host' identified by 'password';
示例如下:


mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.04 sec)


mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> 
或用
mysql> grant all on *.* to 'root'@'%' identified by '123456';

到此, 完成了mysql的安装 及配置!!!

附上配置文件:
[client] 
loose_default-character-set = utf8 
[mysqld] 
basedir = /usr/local/mysql 
datadir = /data/mysql/data 
port = 3306 
server_id = 1 
socket = /data/mysql/data/mysql.sock 
expire_logs_days      = 7 
innodb_file_per_table 
innodb_buffer_pool_size        = 2G 
innodb_thread_concurrency      = 24 
innodb_flush_log_at_trx_commit  = 1 
innodb_log_buffer_size          = 32M 
innodb_log_file_size            = 256M 
innodb_log_files_in_group      = 3 
innodb_max_dirty_pages_pct      = 90 
innodb_lock_wait_timeout        = 120 
wait_timeout            = 60  
interactive_timeout    = 7200 
skip-name-resolve 
character-set-server    = utf8 
back_log                = 50 
max_connections        = 3000 
max_connect_errors      = 32 
max_allowed_packet      = 32M 
binlog_cache_size      = 8M 
max_heap_table_size    = 512M 
tmp_table_size          = 64M 
key_buffer_size        = 16M 
read_buffer_size        = 2M 
read_rnd_buffer_size    = 8M 
bulk_insert_buffer_size = 64M 
sort_buffer_size        = 4M 
join_buffer_size        = 2M 
thread_cache_size      = 64 
thread_stack            = 192K 
query_cache_type        = 1 
query_cache_size        = 256M 
query_cache_limit      = 2M 
ft_min_word_len        = 2 
default_storage_engine  = INNODB 
#default_table_type    = INNODB 
transaction_isolation  = REPEATABLE-READ 
lower_case_table_names  = 1 
#log_slow_queries 
slow_query_log 
long_query_time = 2 
log-short-format 
myisam_sort_buffer_size        = 128M 
myisam_max_sort_file_size      = 10G 
myisam_repair_threads          = 1 
[mysqldump] 
quick 
max_allowed_packet = 32M 
routines 
single-transaction 
hex-blob 
skip-comments  
complete-insert  
skip-disable-keys  
skip-add-locks  
skip-lock-tables  
[isamchk]  
key_buffer      = 512M 
sort_buffer_size = 512M 
read_buffer      = 8M 
write_buffer    = 8M 
[myisamchk] 
key_buffer      = 512M 
sort_buffer_size = 512M 
read_buffer      = 8M 
write_buffer    = 8M 
[mysqlhotcopy] 
interactive-timeout 
# 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  
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 上面的内容转载自:https://www.linuxidc.com/Linux/2016-07/133688.htm?hmsr=toutiao.io

 

安装或使用过程出现的问题

 1.bin/mysqld: error while loading shared libraries: libnuma.so.1

   解决方法:如果安装mysql出现了以上的报错信息.这是却少numactl这个时候如果是Centos就yum -y install numactl就可以解决这个问题了. 
                     ubuntu的就sudo apt-get install numactl就可以解决这个问题了

 

The server quit without updating PID file  原因安装时的设置的datadir basedir 在mysql运行时找不到对应目录

   解决方法:

   1).ps aux|grep mysql 或 ps aux|grep mysqld

   2).kill  -9 上述的mysql服务

   3).vim  xxx/mysql/support-files/mysql.server  修改basedir=xxx/mysql  datadir=自己设置的data位置(如我设置在/data/mysql/data)

   4).移动mysql.serve文件 cp mysql.server /etc/init.d/mysqld (注意/etc/init.d/中 原有的mysqld 需要移除)

   5).vim /etc/my.cnf  修改basedir datadir 与 3)一样的路径 (我这里忘了修改导致出错)

   6).修改datadir的权限 如mkdir  /data/mysql  ,mkdir data/mysql/data ,chown -R mysql:mysql  /data/mysql  (若没有mysql用户,通过groupadd mysql; useradd -r -g mysql mysql 添加)

   7).systemctl restart mysqld

 

重启MySQL的时候出现Warning: Unit file of mysql.service changed on disk, ‘systemctl daemon-reload‘ recommended.错误,根据提示,

  解决方法:

 systemctl daemon-reload

 正常重启MariaDB

 systemctl restart mysql

  即可。其他服务出现类似的情况,也可以使用systemctl daemon-reload来解决。

 

 

 bash:mysql:command not found

  解决方法

 

  有以下几种错误原因:
     1、如果你是使用的 rpm 的安装方式安装的,那么可能的情况就是你没有安装 client 包。
     2、如果你已经安装了还是报这个错的话,那么你可以再重装一遍。(本人将client包重新安装后登录成功)
     3、系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令,我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件。

        3.1、首先得知道mysql命令或mysqladmin命令的完整路径
          比如mysql的路径是:
          /usr/local/mysql/bin/mysql,我们则可以这样执行命令:
          ln -s  /usr/local/mysql/bin/mysql    /usr/bin

       3.2、取得命令执行的绝对路径:whereis   
       

 

转载于:https://www.cnblogs.com/indifferent/p/10977894.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/364408.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

GARFIELD@12-20-2004

克已复礼为仁转载于:https://www.cnblogs.com/rexhost/archive/2004/12/20/79502.html

Java 8的功能基础

Java 8彻底改变了Java。 它很可能是过去10年中最重要的Java版本。 有很多新功能&#xff0c;包括默认方法&#xff0c;方法和构造函数引用以及lambda&#xff0c; 仅举几例 。 更有趣的功能之一是新的java.util.stream API&#xff0c;正如Javadoc所述&#xff0c;该API支持 …

面向对象克隆对象

克隆对象这种写法不是对象克隆&#xff0c;就是把obj的内存地址赋值给obj2. 通过for in克隆 不管是公有的还是私有的都克隆成私有的 Js提供了一个一个克隆的方法 Object.create() Var obj2Object.create(obj) 将obj的所有属性克隆到obj2的原型上 转载于:https://www.cnblogs.…

JSON.stringify()和JOSN.parse()

JSON.stringify()跟JSON.parse() 终于把这两个方法搞清楚了&#xff01;&#xff01;&#xff01; JSON.tringify()&#xff1a;把一个json数据转化成JSON string JSON.stringify({uno:1,dos:2},null,\t)"{"uno": 1,"dos": 2}"JSON.stringfy({u…

查表法实现反正切_关于python实现CRC32的应用和总结

关于python实现CRC32的应用和总结目前使用的Crc计算包含Crc32和Crc32mpeg2两种计算方式。循环冗余检验 CRC 差错检测技术能够证明数据是完整的&#xff0c;是无差错的&#xff08;只是非常近似的认为是无差错的&#xff09;。保证数据可靠性传输的方法包含如下&#xff1a;检验…

bootstrap html5 表单验证,基于Bootstrap+jQuery.validate实现表单验证

这大概是一种惯例&#xff0c;学习前台后台最开始接触的业务都是用户注册和登录。现在社会坚持以人为本的理念&#xff0c;在网站开发过程同样如此。User是我们面对较多的对象&#xff0c;也是较核心的对象。最开始的用户注册和登陆这块&#xff0c;也就尤为重要。用户注册和登…

小程序支付及H5支付前端代码小结

小程序支付和H5支付前端都不需要引入其他的js , 只需要后台将相关的参数 &#xff08; timeStamp: , nonceStr: , package: , signType: MD5, paySign: , &#xff09; 返回来就可以发起微信支付。 小程序支付&#xff1a; wx.requestPayment({timeStamp: ,nonceStr: ,package:…

一道有意思的面试算法题

新年第一篇文章&#xff0c;先祝大家新年快乐&#xff01;&#xff01;那么接下来进入正文。 前言 前阵子突发奇想&#xff0c;突然开始刷leetcode。其中刷到了一道有意思的题目&#xff0c;发现这道题是当时秋招的时候&#xff0c;腾讯面试官曾经问过我的题目。于是分享给大家…

JavaFX技巧1:可调整大小的Canvas

在使用FlexGanttFX时&#xff0c;我不得不处理很多JavaFX Canvas节点。 我正在使用它在时间轴上呈现活动。 甘特图中的每一行都是一个Canvas节点。 用户可以选择单独调整每行的大小。 因此&#xff0c;我不得不找出调整画布大小的最佳方法&#xff0c;这种现成的方法无法调整大…

Javolution 2.2.5 - Java Struct/Union Simplified

Multi-dimensional arrays of struct/union or of primitive types are also supported. Struct API: http://javolution.org/api/javolution/io/Struct.html转载于:https://www.cnblogs.com/perlye/archive/2005/02/04/102192.html

function

function foo(){function bar(){return 3;}return bar();function bar(){return 8;}}1.这个函数返回的是8 function foo1(){var bar1function(){return 3;};return bar1();var bar1function(){return 8;}}2.这个函数返回是3 alert(foo2());function foo2(){var bar2function(){…

12日疯人认证百度云_12月15日上海实习汇总(百度、美图、哔哩哔哩等)

上海实习实习汇总 | 实习内推 | 寒假实习博世 采购助理Job Title: 采购部实习生Job Description:1. Create Purchase Decision (PD), initiate internal approval workflow.2. Maintain basic data in SAP, SupplyOn, SRM, internal system Pilum .etc.3. Issue purchase order…

计算机通识必修课程学什么内容,计算机通识课程教学平台研究与探索.doc

计算机通识课程教学平台研究与探索计算机通识课程教学平台研究与探索摘要&#xff1a;在全国推行教育信息化大背景下&#xff0c;对民办大学计算机类通识课程的教学进行系统定位&#xff0c;结合实际情况利用Moodle开源软件搭建网络教学平台&#xff0c;进而改革优化现有的课程…

CF908G New Year and Original Order

题面 题意翻译 给定$n<10^{700}$&#xff0c;问$1$到$n$中每个数在各数位排序后得到的数的和。答案$mod\;10^97$。 题解 考虑设$f[i][j][k][0/1]$表示前$i$位有$j$位的数字大小$\geq k$&#xff0c;是否严格小于$n$的方案数 转移时&#xff0c;枚举第$i1$位填$p$ $$ f[i1][j…

15必须阅读Java 8教程

Java 8于上个月发布&#xff0c;其中充满了新功能和幕后优化。 互联网在覆盖所有这些新增加的方面&#xff08;包括好的和坏的&#xff09;一直做得很好。 我认为最好汇总一下我们认为是最好的一些教程&#xff0c;以帮助您快速掌握最新信息和需要了解的知识。 Java 8新功能列…

json 对象 数组

一、json写法以及获得其数据的方法 var jsons{ name:wen, age:12, price:qq } console.log(typeof jsons);//object console.log(jsons.name);//wen 二、Array(也是数组) 创建数组方法1&#xff1a;var myArraynew Array(8);创建一个储存8个数据的数组 创建数组方法3:var a…

随机森林和gbdt结合_决策树与迭代决策树(GBDT)

关注数学&#xff0c;关注AI&#xff0c;关注我们公众号ID&#xff1a;Math-AI阅读目录1. 决策树的模型2. 决策树的基本知识3. ID3、C4.5&CART4. Random Forest5. GBDT6. 参考内容今天我们来谈一谈机器学习算法中的各种树形算法&#xff0c;包括ID3、C4.5、CART以及基于集成…

猫眼html源码,50 行代码教你爬取猫眼电影 TOP100 榜所有信息

点击上方“CSDN”&#xff0c;选择“置顶公众号”关键时刻&#xff0c;第一时间送达&#xff01;今天&#xff0c;手把手教你入门 Python 爬虫&#xff0c;爬取猫眼电影 TOP100 榜信息。作者 | 丁彦军本文经授权转自「程序人生」对于 Python 初学者来说&#xff0c;爬虫技能是应…

在Spring中使用jOOQ:CRUD

jOOQ是一个库&#xff0c;可帮助我们重新控制SQL。 它可以从我们的数据库生成代码&#xff0c;并允许我们使用其流畅的API来构建类型安全的数据库查询。 本教程前面的部分向我们介绍了如何配置示例应用程序的应用程序上下文以及如何从数据库中生成代码。 现在&#xff0c;我们…

timeval的时间转换成毫秒之后多大的数据类型可以装下

struct timeval {long tv_sec; /*秒*/long tv_usec; /*微秒*/ }; 秒的定义为long&#xff0c;为了防止溢出&#xff0c;转换成毫秒之后保存在long long中转载于:https://www.cnblogs.com/AKUN-FYK/p/10981984.html