linux mysql安装(离线)
下载文件,地址:https://dev.mysql.com/downloads/mysql/ 下载的文件例如:mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz
安装有问题请访问:这里,(主要是权限和路径问题,整了好几天。。。)
1、设置变量
	  installpath="/usr/local/mysql" && packagename="mysql-8.0.29-linux-glibc2.12-x86_64" && datapath="/data/mysql/data"
2、初始化环境
	  rm -rf $installpath/mysql*
	  mkdir -p  $installpath/$packagename 
	  mkdir -p  $datapath
3、解压
	  tar -xzvf $packagename.tar.gz -C $installpath/
4、用户和组
	  groupadd mysql
	  useradd -r -g mysql -s /bin/false mysql
5、赋权
	  chown -R mysql:mysql $installpath
6、安装
	  ./scripts/mysql_install_db --user=mysql --basedir=$installpath/$packagename/ --datadir=$datapath --lower_case_table_names=1
7、赋权
	  chown -R  root:root  $installpath/$packagename 
	  chown -R mysql:mysql $datapath
8、配置my.cnf(如果有则复制过来改改)
9、启动
	  $installpath/$packagename/support-files/mysql.server start
	
10、修改密码,默认为123456
	  $installpath/$packagename/bin/mysqladmin -u root -h localhost.localdomain password '123456'
	
11、增加远程登录
	  $installpath/$packagename/bin/mysql -u root -h 127.0.0.1 -p '123456'
	
12、关闭防火墙
	  systemctl stop firewalld.service
	  systemctl disable firewalld.service
	  firewalld-cmd --state
	  service iptables stop
	  chkconfig iptables off
	  service iptables status
	
13、把mysql加入到service系统服务
	  cp $installpath/$packagename/support-files/mysql.server /etc/init.d/mysqld
	  chkconfig --add mysqld && chkconfig mysql on
	
14、重启服务
	  service mysqld restart
	  service mysqld status
	
注意:my.cnf文件777会被忽略,授权664即可。
 
