Warning: mkdir(): No space left on device in /data/discuz/upload/source/class/class_core.php on line 91
mysql5.7二进制安装(linux下mysql二进制安装附资料及配置文件)-mysql,二进制,安装,linux,下-IT技术擎-最棒的IT web技术交流社区-( it.techqing.com)
设为首页收藏本站

IT技术擎 - 最棒的IT web技术交流社区

 找回密码
 注册为IT技术擎人

QQ登录

只需一步,快速开始

搜索
热搜: php h5 jquery
查看: 16|回复: 0

[mysql] mysql5.7二进制安装(linux下mysql二进制安装附资料及配置文件)

[复制链接]

3万

主题

3万

帖子

11万

积分

版主

Rank: 7Rank: 7Rank: 7

积分
112600
发表于 2020-2-27 08:20:22 | 显示全部楼层 |阅读模式

一、准备资料

  • 资料

  • 环境
    操作系统 CentOS7.6
    数据库:mysql-5.7.29-linux-glibc2.12-x86_64(二进制文件)
二、准备工作

  • 安装mysql依赖扩展
    1. yum -y install ncurses-devel libaio-devel
    复制代码
  • 创建mysql组及用户
    1. [root@NGINX ~]# groupadd mysql
    2. [root@NGINX ~]# useradd -s /sbin/nologin -g mysql -M mysql
    复制代码
  • 上传mysql文件至家目录
    上传文件并解压
    1. [root@NGINX ~]# tar -zxvf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
    2. [root@NGINX ~]# mv mysql-5.7.29-linux-glibc2.12-x86_64 /usr/local/mysql
    3. ##
    4. [root@NGINX ~]# mkdir /usr/local/mysql/data -p
    5. [root@NGINX ~]# chown mysql.mysql /usr/local/mysql/data/
    6. [root@NGINX ~]# chown mysql.mysql /usr/local/mysql/ -R
    复制代码
三、安装

  • 初始化数据库
    1. [root@NGINX ~]#/usr/local/mysql/bin/mysqld --initialize \
    2. --basedir=/usr/local/mysql/ \
    3. --datadir=/usr/local/mysql/data/ --user=mysql
    复制代码
  • 提示如下说明初始化成功
  1. 2020-02-03T17:19:21.885268Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2. 2020-02-03T17:19:22.145932Z 0 [Warning] InnoDB: New log files created, LSN=45790
  3. 2020-02-03T17:19:22.205145Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  4. 2020-02-03T17:19:22.266136Z 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: 51b82412-46a9-11ea-a597-000c299d5ffd.
  5. 2020-02-03T17:19:22.267329Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  6. 2020-02-03T17:19:23.113327Z 0 [Warning] CA certificate ca.pem is self signed.
  7. 2020-02-03T17:19:23.426412Z 1 [Note] A temporary password is generated for root@localhost: axOIZ8YqgG?;
复制代码

  • 配置环境变量
  1. [root@NGINX ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > >/etc/profile
  2. [root@NGINX ~]# source /etc/profile
复制代码

  • 配置服务
  1. [root@NGINX ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  2. [root@NGINX ~]# service mysql start
  3. Starting MySQL.2020-02-03T17:28:22.352928Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'. ERROR! The server quit without updating PID file (/var/lib/mysql/NGINX.pid).
  4. ###添加些日志权限修改pid文件写权限
复制代码

  • 故障处理全过程
  1. [root@NGINX ~]# service mysql start
  2. Starting MySQL.2020-02-03T17:28:22.352928Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'. ERROR! The server quit without updating PID file (/var/lib/mysql/NGINX.pid).
  3. [root@NGINX ~]# mkdir /var/log/mariadb/ -p
  4. [root@NGINX ~]# echo '' >/var/log/mariadb/mariadb.log|xargs chown mysql.mysql
  5. chown: missing operand after ‘mysql.mysql’
  6. Try 'chown --help' for more information.
  7. [root@NGINX ~]# ^C
  8. [root@NGINX ~]# mkdir /var/log/mariadb/ -p
  9. [root@NGINX ~]# echo '' >/var/log/mariadb/mariadb.log
  10. [root@NGINX ~]# chown mysql.mysql /var/log/mariadb/mariadb.log
  11. [root@NGINX ~]# chown mysql.mysql /var/lo
  12. local/ lock/ log/
  13. [root@NGINX ~]# chown mysql.mysql /var/log/mysql
  14. chown: cannot access ‘/var/log/mysql’: No such file or directory
  15. [root@NGINX ~]# mkdir /var/log/mysql
  16. [root@NGINX ~]# chown mysql.mysql /var/log/mysql
  17. [root@NGINX ~]# service mysql start
  18. Starting MySQL.2020-02-03T17:38:15.918258Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists. ERROR! The server quit without updating PID file (/var/lib/mysql/NGINX.pid).
  19. [root@NGINX ~]# mkdir /var/lib/mysql
  20. [root@NGINX ~]# chown mysql.mysql /var/lib/mysql
  21. [root@NGINX ~]# service mysql start
  22. Starting MySQL..... ERROR! The server quit without updating PID file (/var/lib/mysql/NGINX.pid).
  23. ###还是启动不起来发现my.cnf中datadir没有修改将datadir=/var/lib/mysql
  24. ###改成/usr/local/mysql/data
  25. [root@NGINX ~]# vi /etc/my.cnf
  26. [mysqld]
  27. datadir=/usr/local/mysql/data
  28. socket=/var/lib/mysql/mysql.sock
  29. # Disabling symbolic-links is recommended to prevent assorted security risks
  30. symbolic-links=0
  31. # Settings user and group are ignored when systemd is used.
  32. # If you need to run mysqld under a different user or group,
  33. # customize your systemd unit file for mariadb according to the
  34. # instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]
  35. log-error=/var/log/mariadb/mariadb.log
  36. pid-file=/var/run/mariadb/mariadb.pid#
  37. # include all files from the config directory
  38. #
  39. #!includedir /etc/my.cnf.d
  40. "/etc/my.cnf" 19L, 578C written
  41. [root@NGINX ~]# service mysql start
  42. Starting MySQL. SUCCESS!
复制代码


  • 服务已经成功起来


  • 连接数据库
    依旧很坎坷
  1. [root@NGINX ~]# netstat -nutpl|grep 330
  2. tcp6 0 0 :::3306 :::* LISTEN 22763/mysqld
  3. [root@NGINX ~]# mysql -uroot -paxOIZ8YqgG?;
  4. mysql: [Warning] Using a password on the command line interface can be insecure.
  5. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
  6. [root@NGINX ~]# ln -s /var/lib/mysql.sock /tmp/mysql.sock
  7. [root@NGINX ~]# mysql -uroot -paxOIZ8YqgG?;
  8. mysql: [Warning] Using a password on the command line interface can be insecure.
  9. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
  10. ##找不到sock由于没指定sock登录 可在默认路径添加sock链接
  11. ##/var/lib/mysql/mysql.sock 为本人实例sock路径不清楚的用户可参考
  12. ##/etc/my.cnf中的配置
  13. [root@NGINX ~]# ln -s /var/lib/mysql.sock /tmp/mysql.sock
  14. [root@NGINX ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
  15. ln: failed to create symbolic link ‘/tmp/mysql.sock’: File exists
  16. [root@NGINX ~]# rm /tmp/mysql.sock
  17. rm: remove symbolic link ‘/tmp/mysql.sock’? y
  18. [root@NGINX ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
  19. [root@NGINX ~]# mysql -uroot -paxOIZ8YqgG?;
  20. mysql: [Warning] Using a password on the command line interface can be insecure.
  21. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  22. [root@NGINX ~]# mysql -uroot -paxOIZ8YqgG?
  23. mysql: [Warning] Using a password on the command line interface can be insecure.
  24. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  25. [root@NGINX ~]# /usr/local/mysq/bin/mysql -uroot -paxOIZ8YqgG?;
  26. -bash: /usr/local/mysq/bin/mysql: No such file or directory
  27. [root@NGINX ~]# /usr/local/mysql/bin/mysql -uroot -paxOIZ8YqgG?;
  28. mysql: [Warning] Using a password on the command line interface can be insecure.
  29. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  30. [root@NGINX ~]#
  31. ###密码也进不去了 看来我还要破解密码。。。
复制代码

  • mysql数据库密码忘记找回
  1. [root@NGINX ~]# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql &
  2. [1] 24488
  3. [root@NGINX ~]# 2020-02-03T18:24:19.611951Z mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
  4. 2020-02-03T18:24:19.643658Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data[root@NGINX ~]# netstat -nutpl |grep 330
  5. tcp6 0 0 :::3306 :::* LISTEN 24638/mysqld
  6. [root@NGINX ~]# mysql
  7. Welcome to the MySQL monitor. Commands end with ; or \g.
  8. Your MySQL connection id is 2
  9. Server version: 5.7.29 MySQL Community Server (GPL)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql > set password=password("Cmm111111%%");
  12. ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
  13. mysql > update mysql.user set authentication_string=password("Cmm111111%%") where user='root';
  14. Query OK, 1 row affected, 1 warning (0.01 sec)
  15. Rows matched: 1 Changed: 1 Warnings: 1mysql > flush priliveges;
  16. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priliveges' at line 1
  17. mysql > flush privileges;
  18. Query OK, 0 rows affected (0.00 sec)
  19. mysql > exit;
  20. Bye
  21. [root@NGINX ~]# netstat -nutpl |grep 330
  22. tcp6 0 0 :::3306 :::* LISTEN 24638/mysqld
  23. [root@NGINX ~]# killall mysqld
  24. [root@NGINX ~]# 2020-02-03T18:31:40.272008Z mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended[1]+ Done /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql
  25. [root@NGINX ~]# netstat -nutpl |grep 330
  26. [root@NGINX ~]# service mysql start
  27. Starting MySQL. SUCCESS!
  28. [root@NGINX ~]# /usr/local/mysql/bin/mysql -uroot -pCmm111111%%
  29. mysql: [Warning] Using a password on the command line interface can be insecure.
  30. Welcome to the MySQL monitor. Commands end with ; or \g.
  31. Your MySQL connection id is 2
  32. Server version: 5.7.29Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
  33. affiliates. Other names may be trademarks of their respective
  34. owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql > show databases;
  35. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  36. ##破解密码后首次进入操作需要执行如下操作
  37. mysql > set password=password("Cmm111111%%");
  38. Query OK, 0 rows affected, 1 warning (0.00 sec)mysql > show databases;
  39. +--------------------+
  40. | Database |
  41. +--------------------+
  42. | information_schema |
  43. | mysql |
  44. | performance_schema |
  45. | sys |
  46. +--------------------+
  47. 4 rows in set (0.00 sec)
复制代码
END资料下载
关注公众号: 扣丁曼回复"mysql57”获取素材下载链接。

  • 点赞  

  • 收藏

  • 分享


    • 文章举报
  
扣丁曼发布了11 篇原创文章· 获赞 0· 访问量 485 私信 关注



上一篇:nginx 负载均衡
下一篇:PHP-009-【特殊变量】-服务器变量-$_SERVER
该用户未在地球留下任何的痕迹

本版积分规则

QQ|小黑屋|帮助|IT技术擎 ( 沪ICP备15054863号  

GMT+8, 2020-4-11 03:29

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表