MySQL5.7安装
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,1、下载安装包wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz2、解
千家信息网最后更新 2026年11月02日MySQL5.7安装
1、下载安装包
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz2、解压到/opt下
[root@Master opt]# tar xvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz[root@Master opt]# lltotal 628712drwxr-xr-x. 9 root root 4096 Jul 6 19:47 mysql-5.7.22-linux-glibc2.12-x86_64-rw-r--r--. 1 root root 643790848 Jul 6 11:44 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz3、作软链接到/usr/local/mysql
[root@Master opt]# ln -s /opt/mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql[root@Master opt]# ll /usr/local/total 40drwxr-xr-x. 2 root root 4096 Sep 23 2011 bindrwxr-xr-x. 2 root root 4096 Sep 23 2011 etcdrwxr-xr-x. 2 root root 4096 Sep 23 2011 gamesdrwxr-xr-x. 2 root root 4096 Sep 23 2011 includedrwxr-xr-x. 2 root root 4096 Sep 23 2011 libdrwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexeclrwxrwxrwx. 1 root root 40 Jul 6 20:01 mysql -> /opt/mysql-5.7.22-linux-glibc2.12-x86_64drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbindrwxr-xr-x. 5 root root 4096 Feb 16 2017 sharedrwxr-xr-x. 2 root root 4096 Sep 23 2011 src4、创建用户
[root@Master opt]# groupadd mysql [root@Master opt]# useradd -g mysql -s /sbin/nologin -d /usr/local/mysql/ -M mysql5、环境变量
[root@Master opt]# echo PATH=$PATH:/usr/local/mysql/bin >>/etc/profile [root@Master opt]# source /etc/profile6、创建必须的目录
mkdir -p /data/mysql/mysql3306/{data,tmp,logs}7、生成my.cnf(根据自己需求自动生成)
叶总的配置文件生成工具
http://imysql.com/my-cnf-wizard.html
8、目录权限
[root@Master /]# chown -R mysql:mysql /data/mysql/mysql3306/[root@Master /]# chown -R mysql:mysql /usr/local/mysql9、数据库初始化
[root@Master /]# mysqld --defaults-file=/etc/my.cnf --initialize --user=user --basedir=/usr/local/mysql/ --datadir=/data/mysql/mysql3306/data/10、数据库密码(.lZ!-2t2-n9s)
[root@Master data]# more /data/mysql/mysql3306/data/dataerror.log2018-07-06T13:46:32.795821Z 1 [Note] A temporary password is generated for root@localhost: .lZ!-2t2-n9s11、启动数据库
[root@Master support-files]# pwd/usr/local/mysql/support-files[root@Master support-files]# cp mysql.server /etc/init.d/mysqld[root@Master support-files]# /etc/init.d/mysqld startStarting MySQL.. SUCCESS!12、登录数据库
输入第10步的密码Starting MySQL.. SUCCESS! [root@Master support-files]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.22-logCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.root@Master 21:57: [(none)]> root@Master 21:57: [(none)]> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement13、改root密码
[root@Master support-files]# mysqladmin -uroot -p password 'root'Enter password: mysqladmin: [Warning] Using a password on the command line interface can be insecure.Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety14、登录数据库
[root@Master support-files]# mysql -uroot -proot 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 5Server version: 5.7.22-log MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.root@Master 22:01: [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)问题:
初始化时遇到报错error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory解决:
yum -y install numactl.x86_64
数据
数据库
密码
生成
目录
登录
变量
工具
文件
权限
环境
用户
自动生成
链接
问题
需求
输入
配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
咖啡
精品咖啡豆
互联网新科技
科技互联网产品
没上市的科技互联网公司
高科技与互联网
喔噻互联网科技
四个字互联网科技公司取名
互联网科技创新企业排名
青岛中康互联网医疗科技有限公司
须眉科技是互联网公司吗
中国科技互联网公司收入
河南猎农互联网科技有限公司
昭通互联网科技选哪家
996高科技互联网公司
长沙互联网科技
上海京穆互联网科技有限公司
工业互联网科技成果转化
信承诺互联网科技有限公司
上海旺乐尼互联网科技有限公司
瑰夏咖啡
广东猪兼强互联网科技有限公司
互联网中国科技
重庆科技学院互联网
彤创互联网科技有限公司
长沙茂晟互联网科技有限公司
互联网科技实习生岗位
互联网金融运营模式中的金融科技
中国互联网公司的科技投入
互联网 科技节活动 微视频大赛