怎么自动安装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。
1、Mysql自动安装5.7Shell脚本
如果您觉得文本对您有帮助,请打赏,谢谢。
新建执行脚本:mysql_install.sh,并添加执行权限
#!/bin/bash
#zhouyihua V0.1 2021.07.08
#For centos 7.0
# 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 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 mysql.user set authentication_string=password('Oracle1234!@#$') where user='root';
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;
GRANT ALL PRIVILEGES ON *.* TO 'iam'@'%' IDENTIFIED BY 'Oracle1234!@#$';
EOF
默认情况下,在安装MySQL数据库系统时会自动安装MySQL
会。在安装MySQL时,会自动安装一个名为mysql的数据库,该数据库中的表都是权限表。关于安装mysql数据库后系统自动创建的数据库的相关内容,安装mysql数据库后系统会自动创建安装数据库,统一默认安装在一个目录中。
本文题目:怎么自动安装mysql 怎么自动安装系统
网页路径:http://pwwzsj.com/article/dddehij.html