189 8069 5689

mysql怎么自动安装 手动安装mysql

2、Mysql自动安装8.0Shell脚本

如果您觉得文本对您有帮助,请打赏,谢谢。

创新互联是一家专注于成都做网站、网站制作与策划设计,神池网站建设哪家好?创新互联做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:神池等地区。神池做网站价格咨询:028-86922220

新建执行脚本:mysql_install.sh,并添加执行权限

#!/bin/bash

#zhouyihua V0.1 2021.07.08

#For centos 7.0 8.0

#v 0.2

# add DNS

echo "----------  Add DNS  --------"

echo "nameserver 8.8.8.8" /etc/resolv.conf

#stop firewall

systemctl stop firewalld

if [ $? -ne 0 ]; then

echo "Firewall stop failed"

else

echo "Firewall stop success"

fi

#download mysql yum source

wget

#install mysql yum source

rpm -ivh mysql80-community-release-el7-3.noarch.rpm

#enable 5.7

#sed -i '21s/enabled=0/enabled=1/g' /etc/yum.repos.d/mysql-community.repo

#sed -i '21s/enabled=0/enabled=1/g' /etc/yum.repos.d/mysql-community.repo

#disable 8.0

#sed -i '28s/enabled=1/enabled=0/g' /etc/yum.repos.d/mysql-community.repo

#install mysql

yum -y module disable mysql

yum -y remove mariadb-libs

yum install -y mysql-community-server

#config mysql

echo "-----------  Config my.cnf  ----------"

sed -i '/\[mysqld\]/a\lower_case_table_names=1' /etc/my.cnf

sed -i '/\[mysqld\]/a\skip-grant-tables' /etc/my.cnf

#start mysql

echo "----------  Starting mysql service  ----------"

systemctl start mysqld.service

mysql -uroot -p123456  EOF

use mysql;

update user set authentication_string='' where user='root' ;

flush privileges;

ALTER user 'root'@'localhost' IDENTIFIED BY '?CZJh8JWxvH';

EOF

echo "----------  Annotation skip grant tables in my.cnf    ----------"

sed -i 's/skip-grant-tables/\#skip-grant-tables/g' /etc/my.cnf

echo "----------  Restart mysql service  ----------"

systemctl restart mysqld.service

echo "----------  Grant all privileges  ----------"

mysql -uroot -p'Oracle1234!@#$'    --connect-expired-password -e "alter user 'root'@'localhost' identified by 'Oracle1234!@#$';"

mysql -u root -p'Oracle1234!@#$'  EOF

use mysql;

CREATE USER 'maxkey'@'%' IDENTIFIED BY 'Oracle1234!@#$';

GRANT ALL ON *.* TO 'maxkey'@'%';

EOF

参考:

先设置grant_skip_tables

1.  use mysql

2. update user set authentication_string='' where user='root' ;    如果这个字段有值,先置为空

3. flush privileges    刷新权限表

4.ALTER user 'root'@'localhost' IDENTIFIED BY 'Tianya1234'    修改root 密码

参考:

如何自定义安装 mysql

MySQL安装包安装方式

在MySQL官网下载社区版mysql-installer-community-5.6.31.0,此版本为免费的。

(1)选择接受许可条款“I accept the license terms”

如何安装MySQL,MySQL两种安装方式

(2)如果只想安装MySQL服务,选择“Server only”,建议选择Server only”,点击“Next”

如何安装MySQL,MySQL两种安装方式

(3)点击“Execute”,执行安装

如何安装MySQL,MySQL两种安装方式

(4)安装完成点击下一步

如何安装MySQL,MySQL两种安装方式

如何安装MySQL,MySQL两种安装方式

(5)进行服务配置,MySQL默认端口为3306

如何安装MySQL,MySQL两种安装方式

(6)为root用户设置密码。可添加一个具有普通用户权限的MySQL用户账户,也可不添加,一般不添加用户,而是用root账户。

如何安装MySQL,MySQL两种安装方式

(7)以系统用户运行windows服务,在Windows下MySQL服务名为:mysql56,后面步骤将讲到mysql56的用处。而且要牢牢记住此名字。

如何安装MySQL,MySQL两种安装方式

(8)请求服务配置

如何安装MySQL,MySQL两种安装方式

如何安装MySQL,MySQL两种安装方式

(9)产品配置信息,安装MySQL Server 5.6.31完成。

如何安装MySQL,MySQL两种安装方式

如何安装MySQL,MySQL两种安装方式

(10)配置环境变量

前面步骤完成后安装好MySQL,为MySQL配置环境变量。MySQL默认安装在C:\Program Files下。

1)新建MYSQL_HOME变量,并配置:C:\Program Files\MySQL\MySQL Server 5.6

MYSQL_HOME:C:\Program Files\MySQL\MySQL Server 5.6

2)编辑path系统变量,将%MYSQL_HOME%\bin添加到path变量后。配置path环境变量,也可不新建MYSQL_HOME变量,而是直接将MySQL安装目录下的bin配置到path变量下,即:C:\Program Files\MySQL\MySQL Server 5.6\bin

Path:%MYSQL_HOME%\bin

或Path:C:\Program Files\MySQL\MySQL Server 5.6\bin

如何安装MySQL,MySQL两种安装方式

如何安装MySQL,MySQL两种安装方式

(11)测试是否安装成功

以管理员权限运行命令提示符,用net start mysql56启动MySQL服务。用net stop mysql56关闭MySQL服务。其中mysql56为Windows下MySQL的服务名。

如何安装MySQL,MySQL两种安装方式

如何安装MYSQL

使用yum安装mysql数据库的软件包 [root@xuegod63 ~]# yum -y install mariadb-server mariadb 。

注:  mariadb-server   #MariaDB数据库 mariadb      # MariaDB服务器Linux下客户端 。

注:从centos7系统开始,系统中自带的mysql数据库变成了mariadb-server,mariadb-server和mysql操作上一样。mariadb-server是mysql的一个分支。

启动数据库服务[root@xuegod63 ~]# systemctl start  mariadb  #启动MariaDB服务。[root@xuegod63 ~]# systemctl enable  mariadb  #设置开启自动启动MariaDB服务。

安装完mariadb-server后,运行mysql_secure_installation去除安全隐患,[root@xuegod63 ~]# mysql_secure_installation #进入安全配置导向。

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQLSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current,password for the root user. If you've just installed MySQL, and,you haven't set the root password yet, the password will be blank,,so you should just press enter here.Enter current password for root (enter for none):   #初次运行直接回车,因为root用户没有密码。

OK, successfully used password, moving on,Setting the root password ensures that nobody can log into the MySQL,root user without the proper authorisation.,Set root password? [Y/n] Y #是否设置root用户密码,输入Y。

New password: 123456   #新密码123456,Re-enter new password: 123456,Password updated successfully!Remove anonymous users? [Y/n] Y   #是否删除匿名用户,生产环境建议删除,所以直接回车或Y。

Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] Y  #是否禁止root远程登录,根据自己的需求选择Y/n并回车建议禁止。

Success!By default, MariaDB comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] Y   #是否删除test数据库,直接回车或Y。


本文名称:mysql怎么自动安装 手动安装mysql
标题链接:http://cdxtjz.cn/article/hehogp.html

其他资讯