概述
1、解压安装包
tar -zxf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
ls /usr/local/
bin
games
include
lib64
mysql-5.7.28-linux-glibc2.12-x86_64
share
etc
httpd
lib
libexec
sbin
2、创建用户
useradd -M -s /sbin/nologin mysql
mkdir -p /mysql/data
cd /mysql/data
chown -R mysql.mysql ./
cd /usr/local/
mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql
cd mysql
chown -R mysql:mysql ./
./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data --initialize
2020-02-25T05:38:43.971797Z 1 [Note] A temporary password is generated for root@localhost: *h8x?mgdKkvq
#使用生成的临时密码登录数据库
3、编辑配置文件
[mysqld]
datadir=/mysql/data
#存放数据目录
basedir=/mysql/data
#安装目录
socket=/tmp/mysql.sock
#sock存放目录
port=3306
#默认端口
skip-name-resolve
#禁用DNS解析
character-set-server=utf8
#服务端使用的字符集默认为8比特编码的latin1字符集
default-storage-engine=INNODB
# 创建新表时将使用的默认存储引擎
lower_case_table_names=1
#不区分大小写
max_allowed_packet=16M
#以字节形式发送给数据库的数据包大小
sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
#不开启sql严格模式
[mysqld_safe]
log-error=/mysql/data/mysql.log
pid-file=/mysql/data/mysql.pid
4、启动MySQL并设置开机自启
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
vim /etc/init.d/mysqld
在第46、47行修改如下111
basedir=/usr/local/mysql
datadir=/mysql/data
systemctl start mysqld
systemctl status mysqld
5、修改数据库密码
ln -s /usr/local/mysql/bin/* /usr/local/bin/
./bin/mysqladmin -u root -p'*h8x?mgdKkvq' password '123456'
#如果这条不生效时,登录数据库中修改密码
mysql -u root -p123456
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> q
Bye
mysql -uroot -p
Enter password:
#输入生成的临时密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
#更改密码
Query OK, 0 rows affected (0.00 sec)
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
#密码永不过期
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
6、rpm方式安装MySQL
适合要求不高,并发量也不高的场景
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
systemctl start mysqld
systemctl status mysqld.service
systemctl enable mysqld
grep 'temporary password' /var/log/mysqld.log
#获取临时密码,登录MySQL,在进行修改密码即可
最后
以上就是朴实小蝴蝶为你收集整理的MySQL-5.7二进制安装的全部内容,希望文章能够帮你解决MySQL-5.7二进制安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复