首页 > 数据库 >二进制安装mysql

二进制安装mysql

时间:2022-12-18 22:12:59浏览次数:93  
标签:13 rw 二进制 0.0 40 -- mysql 安装

下载地址

https://downloads.mysql.com/archives/community/

将下载好的二进制安装包放到服务器上

$ ll -h
总用量 636M
-rw-r--r-- 1 root root 636M 5月   1 13:11 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz

解压重命名安装包

$ cd /data/
$ ll -h
总用量 636M
-rw-r--r-- 1 root root 636M 5月   1 13:11 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
$ tar xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
#重命名
$ mv /usr/local/mysql-5.7.37-linux-glibc2.12-x86_64 /usr/local/mysql
$ cd /usr/local/mysql

新建启动mysql的用户

$ useradd -r -s /bin/false mysql
$ id mysql
uid=988(mysql) gid=982(mysql) 组=982(mysql)

创建数据和日志文件夹以及修改属主属组

$ mkdir /data/mysql
$ mkdir /usr/local/mysql/logs
$ chown -R mysql:mysql /data/mysql
$ chown -R mysql:mysql /usr/local/mysql
$ ll
总用量 272
drwxr-xr-x  2 mysql mysql   4096 5月   1 13:28 bin
drwxr-xr-x  2 mysql mysql     55 5月   1 13:28 docs
drwxr-xr-x  3 mysql mysql   4096 5月   1 13:28 include
drwxr-xr-x  5 mysql mysql    230 5月   1 13:28 lib
-rw-r--r--  1 mysql mysql 259253 11月 30 04:09 LICENSE
drwxr-xr-x  2 mysql mysql      6 5月   1 13:33 logs
drwxr-xr-x  4 mysql mysql     30 5月   1 13:28 man
-rw-r--r--  1 mysql mysql    566 11月 30 04:09 README
drwxr-xr-x 28 mysql mysql   4096 5月   1 13:28 share
drwxr-xr-x  2 mysql mysql     90 5月   1 13:28 support-files
$ ll /data/
总用量 650984
drwxr-xr-x 2 mysql mysql         6 5月   1 13:32 mysql
-rw-r--r-- 1 root  root  666603757 5月   1 13:11 mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz

修改配置文件

#查看配置文件,发现时间是非常早的
$ ll /etc/my.cnf
-rw-r--r--. 1 root root 570 9月  30 2020 /etc/my.cnf
$ date
2022年 05月 01日 星期日 13:35:30 CST
#清空配置文件
$ echo > /etc/my.cnf
#修改配置文件
$ vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/logs/mysqld.pid
innodb_log_file_size=1024M

#修改配置文件属主属组
$ chown -R mysql:mysql /etc/my.cnf
$ ll /etc/my.cnf
-rw-r--r-- 1 mysql mysql 165 5月   1 13:36 /etc/my.cnf

初始化数据库

$ /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
$ ll /data/mysql
总用量 2109508
-rw-r----- 1 mysql mysql         56 5月   1 13:40 auto.cnf
-rw------- 1 mysql mysql       1680 5月   1 13:40 ca-key.pem
-rw-r--r-- 1 mysql mysql       1112 5月   1 13:40 ca.pem
-rw-r--r-- 1 mysql mysql       1112 5月   1 13:40 client-cert.pem
-rw------- 1 mysql mysql       1676 5月   1 13:40 client-key.pem
-rw-r----- 1 mysql mysql        436 5月   1 13:40 ib_buffer_pool
-rw-r----- 1 mysql mysql   12582912 5月   1 13:40 ibdata1
-rw-r----- 1 mysql mysql 1073741824 5月   1 13:40 ib_logfile0
-rw-r----- 1 mysql mysql 1073741824 5月   1 13:40 ib_logfile1
drwxr-x--- 2 mysql mysql       4096 5月   1 13:40 mysql
drwxr-x--- 2 mysql mysql       8192 5月   1 13:40 performance_schema
-rw------- 1 mysql mysql       1676 5月   1 13:40 private_key.pem
-rw-r--r-- 1 mysql mysql        452 5月   1 13:40 public_key.pem
-rw-r--r-- 1 mysql mysql       1112 5月   1 13:40 server-cert.pem
-rw------- 1 mysql mysql       1680 5月   1 13:40 server-key.pem
drwxr-x--- 2 mysql mysql       8192 5月   1 13:40 sys

创建服务和客户端的软连接

$ ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
$ ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

设置开机自启

$ chkconfig --add mysqld
$ chkconfig --level 35 mysqld off
$ chkconfig --list

注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

mysqld         	0:关	1:关	2:关	3:开	4:关	5:开	6:关
netconsole     	0:关	1:关	2:关	3:关	4:关	5:关	6:关
network        	0:关	1:关	2:开	3:开	4:开	5:开	6:关

启动测试

查看初始化密码

$ tail -100 logs/mysqld.log | grep password
2022-05-01T05:40:27.329835Z 1 [Note] A temporary password is generated for root@localhost: ?%t,Q,e##9py

显示密码为?%t,Q,e##9py

启动登录

$ service mysqld start
Starting MySQL. SUCCESS! 
$ netstat -ntlp
#显示正常启动
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      612/rpcbind         
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1282/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1031/sshd           
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1029/cupsd          
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1240/master         
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      1434/sshd: root@pts 
tcp6       0      0 :::3306                 :::*                    LISTEN      2309/mysqld         
tcp6       0      0 :::111                  :::*                    LISTEN      612/rpcbind         
tcp6       0      0 :::22                   :::*                    LISTEN      1031/sshd           
tcp6       0      0 ::1:631                 :::*                    LISTEN      1029/cupsd          
tcp6       0      0 ::1:25                  :::*                    LISTEN      1240/master         
tcp6       0      0 ::1:6010                :::*                    LISTEN      1434/sshd: root@pts 

登录

$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

发现简单的查数据库都无法操作,提示需要修改密码

mysql> SET PASSWORD = PASSWORD('111111');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)

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

--或者直接用alter user 修改
mysql> alter user 'root'@'localhost' identified by '111111';

重新登录操作测试

$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

已经可以正常操作了

二进制安装数据库完成

标签:13,rw,二进制,0.0,40,--,mysql,安装
From: https://www.cnblogs.com/guangdelw/p/16991048.html

相关文章

  • Ubuntu22.04 安装搜狗输入法
    下载搜狗输入法下载地址https://shurufa.sogou.com/linux也可以命令下载wgethttps://ime.sogouimecdn.com/202212182151/3b0d13beea2c2eb8382b6011c93b020f/dl/gzind......
  • yum在线安装mysql
    下载https://dev.mysql.com/downloads/repo/yum/上传服务器$rz-Erzwaitingtoreceive.$ll总用量12-rw-r--r--1rootroot112885月114:17mysql80-co......
  • MySQL发行版的选择
    MySQL官方发行版MySQL是最流行的数据库,主要特点:简单:MySQL使用很简单,任何稍微有IT背景的技术人员都可以无师自通地参照文档安装运行和使用MySQL,这几乎没有什么门槛。开......
  • 修改mysql密码规则
    建议个人测试学习使用,切勿在生产环境中使用--查看规则mysql>showvariableslike'validate_password%';+--------------------------------------+--------+|Variab......
  • cppconn cpp create table in cpp file ,show current date time in mysql cli via s
    //Model/mysqlhelper.h#ifndef__mysqlhelper_h__#define__mysqlhelper_h__#include<chrono>#include<ctime>#include<fstream>#include<iomanip>#include<i......
  • Mac 使用 brew 安装 mysql
    最近需要用到MySQL来开发项目,所以在Mac配置了下MySQL的环境。1、使用brewinstallmysql安装MySQL安装完毕后会有以下提示信息,告诉我们初始安装好后root账户......
  • centos7 编译安装mysql
    mysql5.7版本和8版本的编译略有不同,所以这里分开讲。源码编译、安装MySQL5.7Mysql5.7版本更新后有很多变化,最主要的变化是安装MySQL必须要有BOOST库,不过MySQL的官网源码......
  • MySQL HA(High Availability) 数据库高可用工具Orchestrator 基本原理
    目录1.实例探测(instancesdiscover/poll)2.故障分析(failureanalysis)3.故障恢复(failurerecovery)4.总结Orchestrator是一款开源的MySQL数据库高可用HA工具。它稳定可靠,......
  • Python安装time库失败?不是吧阿sir你还不知道内置模块不用下载吧
    嗨嗨,今天给python安装time库,一直报错,换源等办法都试过了直到我看到Python中有以下常用模块不用单独安装random模块sys模块time模块os系统操作re正则操作json模块......
  • jclasslib安装和使用
      这是一款可以查询class文件的插件,在代码运行后才会显示出来  ......