mysql脚本怎么安装 mysql的脚本使用什么语言
如何在linux下安装mysql
第一步:安装:
成都创新互联公司专业为企业提供古丈网站建设、古丈做网站、古丈网站设计、古丈网站制作等企业网站建设、网页设计与制作、古丈企业网站模板建站服务,十年古丈做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
tarmysql-5.5.48-linux2.-x86_64.tar.gz
Copy到指定的路径下:
cpmysql-5.5.48-linux2.6-x86_64 /usr/local/mysql -r
添加系统mysql组合mysql用户:
执行命令:groupaddmysql和useradd -r -g mysql mysql
安装数据库:
进入安装mysql软件目录:执行命令 cd/usr/local/mysql
修改当前目录拥有者为mysql用户:执行命令chown -R mysql:mysql ./
安装数据库:执行命令./scripts/mysql_install_db --user=mysql
修改当前目录拥有者为root用户:执行命令chown -R root:root ./
修改当前data目录拥有者为mysql用户:执行命令chown -R mysql:mysql data
到此数据库安装完毕
启动mysql服务和添加开机启动mysql服务:
添加开机启动:执行命令cpsupport-files/mysql.server /etc/init.d/mysql,把启动脚本放到开机初始化目录
启动mysql服务:执行命令servicemysql start
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安装、设定远程登录、data目录迁移
默认mysql是安装在/var/lib/mysql目录下,但是一般只有15G空间,令人至疯,所以装完必须迁移
cd /homemkdir data
mysqladmin -u root -p shutdown
[root@test1 mysql]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
最后,需要修改MySQL启动脚本/etc/init.d/mysqld,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存放路径:home/data/mysql。
[root@test1 etc]# vi /etc/init.d/mysql#datadir=/var/lib/mysql(注释此行)datadir=/home/data/mysql (加上此行)
如果是CentOS还要改 /usr/bin/mysqld_safe 相关文件位置;
最后 做一个mysql.sock 链接:
in -s /home/data/mysql/mysql.sock /var/lib/mysql/mysql.sock
7、重新启动MySQL服务
/etc/init.d/mysql start或者service mysql restart
8、修改整个目录权限
chown -R mysql:mysql /home/data/mysql/
chmod -R 777 /home/data/mysql/*
分享题目:mysql脚本怎么安装 mysql的脚本使用什么语言
网页地址:http://pwwzsj.com/article/ddoedcs.html