mysql 5.7 二进制普通安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 5.7 二进制普通安装相关的知识,希望对你有一定的参考价值。

1 官网下载mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
2 可以先检查系统中的Mysql或mariadb,如果存在将其卸载
[root@bogon ~]# rpm -qa |grep mysql
php-mysql-5.4.16-46.1.el7_7.x86_64
[root@bogon ~]# rpm -qa |grep mariadb
mariadb-libs-5.5.64-1.el7.x86_64
mariadb-server-5.5.64-1.el7.x86_64
mariadb-5.5.64-1.el7.x86_64
[root@bogon ~]# yum -y remove php-mysql-5.4.16-46.1.el7_7.x86_64
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.4.16-46.1.el7_7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size

3 useradd -M -s /sbin/nologin -r mysql  //-M不创建主目录,-s /sbin/nologin不允许登录,-r创建的是系统用户
4 tar zxf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz -C /usr/local/  //解压
cd /usr/local/
mv mysql-5.7.26-linux-glibc2.12-x86_64/ mysql
cd mysql
mkdir data  //创建数据目录
chown -R mysql.mysql /usr/local/mysql/
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

    //显示root@localhost第一次登录的随机密码 注意这里的秘密

[root@bogon mysql]# vi /etc/my.cnf

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
socket=/usr/local/mysql/mysql.sock
character-set-server=utf8
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
[mysql]
socket=/usr/local/mysql/mysql.sock
[client]
socket=/usr/local/mysql/mysql.sock
环境变量的配置
[root@bogon mysql]# vi /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
[root@bogon mysql]# source /etc/profile.d/mysql.sh
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
chmod +x /etc/init.d/mysqld
[root@bogon mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[root@bogon mysql]#
mysql
mysql -uroot -p‘e>;Yl?WVp7Na‘

mysql> set password for root@localhost=password(‘123456‘);

以上是关于mysql 5.7 二进制普通安装的主要内容,如果未能解决你的问题,请参考以下文章

mysql 5.7 二进制安装

Liunx 下MYSQL 5.7 二进制安装

MySQL 5.7二进制安装

MySQLLinux下MySQL 5.55.6和5.7的RPM二进制和源码安装

(综合知识)RPM和二进制安装Mysql(含指定5.7安装)

mysql 5.7安装脚本