安装
/*先查看linux版本。*/
getconf LONG_BIT
/*下载mysql(直接打开迅雷粘贴下载)。*/
http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.7/mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
/*检查系统是否安装过mysql*/
rpm -qa|grep -i mysql
rpm -qa|grep -i mariadb
/*如果安装了就卸载(我这里自带的mariadb是mariadb-libs-5.5.60-1.el7_5.x86_64)*/
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
/*删除老版本mysql的开发头文件和库*/
rm -rf /etc/my.cnf
rm -rf /var/lib/mysql
/*在/usr/local解压*/
tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
/*安装相关依赖*/
yum install perl
yum install net-tools
/*依次安装,如果安装出现NOKEY问题,则在后面再追加--force --nodeps*/
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm
/*启动mysql*/
systemctl start mysqld
/*查看是否启动(Active: active (running)表示启动;Active: active (dead)表示未启动)*/
systemctl status mysqld
/*查看临时密码*/
grep password /var/log/mysqld.log
/*登录mysql*/
mysql -u root -p
/*修改密码(密码必须由大、小写字母、下划线、数字组合,缺一不可。)*/
set password = password("Aa_123456");
/*退出数据库,并测试用新密码登录。*/
exit(如果exit退出不了,尝试用quit退出。)
mysql -u root -p
/*登录数据库,开启远程连接*/
GRANT ALL PRIVILEGES ON *.* TO 'root' @'%' IDENTIFIED BY '这里写密码' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
/*重启数据库*/
systemctl restart mysqld
/*关闭防火墙*/
systemctl stop firewalld.service
/*查看防火墙状态( Active: inactive (dead) 表示防火墙已经关闭。)*/
systemctl status firewalld.service
/*永久关闭防火墙*/
systemctl disable firewalld.service
/*用远程数据库连接工具测试是否可以连接。*/