Centos7 mysql8.tar.gz installation

The installation: mysql-8.0.16.tar.gz version

mysql official website download link: https://dev.mysql.com/downloads/mysql/

Wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.16-el7-x86_64.tar.gz command can also download and install the package on Centos

Start: Log in as the root user

cd / root / / * switch to the root directory * / 
wget HTTPS: // cdn.mysql.com // Downloads / MySQL - 8.0 / MySQL - 8.0 . 16 - EL7 - x86_64.tar.gz / * wait for the download to download the installation package completed * /
the tar -zxvf /root/mysql-8.0.16-el7-x86_64.tar.gz -C / usr / local / / * extract the installation package to the specified directory * /
Music Videos /usr/local/mysql-8.0.16 -el7-x86_64.tar.gz / usr / local / mysql / * modify the folder name as the installation directory * /
mkdir / usr / local / mysql / MySQLdb / * create mysql data storage directory * /
/*给安装目录赋予权限*/

chmod -R 777 /usr/usr/local/mysql
chomd -R 777 /usr/local/mysql/mysqldb

cd /usr/local/mysql /*进入目录*/
groupadd mysql   /*创建mysql组*/
useradd -r -g mysql -s /bin/false mysql /*创建MySQL用户,但该用户不能登录(-s/bin/false参数指定mysql用户仅拥有所有权,而没有登录权限)*/
chomd -R mysql:mysql ./ /*把刚刚创建的mysql用户加入到mysql组下*/

/*创建mysql安装初始化文件 加入以下配置保存*/
vi /etc/my.cnf
-----------------------------------------------------

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/mysqldb
# 允许最大连接数
max_connections=10000
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

-----------------------------------------------------------------------

/*开始安装*/

cd /usr/local/mysql/bin 

./mysqlld --initialize --console  /*安装*/

 

 

cd ../support-files

chmod -R 777 /usr/local/mysql   /*重新赋予权限*/

./mysql.server start  /*启动mysql*/

cp mysql.server /etc/init.d/mysqld   /*将mysql加入到系统进程中*/

service mysql restart   /*重启mysql服务*/

cd ../bin

./mysql -uroot -p刚刚初始化安装时的密码    /*登录mysql*/

mysq> alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';   /*修改密码为root*/

 

/*允许远程登录*/

mysql> use mysql mysql> update user set user.Host='%'where user.User='root';

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

/*重启mysql服务:*/

service mysqld restart

/*加入系统环境变量*/

vi /etc/profile   

加入export PATH=$PATH:/usr/local/mysql/bin即可

/*执行链接命令*/

ln -s /usr/local/mysql/bin/mysql /usr/bin

 

/*开机启动*/

vi /etc/rc.local

添加service mysqld start

 

/*永久关闭防火墙*/

systemctl status firewalld.service    /*查看防火墙状态*/

 

/*绿色表示防火墙开启*/

systemctl stop firewalld.service    /*关闭防火墙命令*/

systemctl status firewalld.service    /*查看防火墙状态*/

 

/*红色表示防火墙已经关闭*/

 ------------------------安装完成--------------------

 

Guess you like

Origin www.cnblogs.com/Zhusi/p/11117731.html