- 管理员运行: su
- 安装和卸载mysql
安装mysql:
下载mysql的repo源:$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安装rpm包:$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装mysql:$ sudo yum install mysql-server
查看临时密码:grep "password" /var/log/mysqld.log
启动mysql: systemctl start mysqld.service
查看mysql状态:systemctl status mysqld.service
登录mysql: mysql -uroot -p
修改密码:alter user 'root'@'localhost' identified by '*********'
查看mysql参数:SHOW VARIABLES LIKE 'validate_password%'; 或 select @@validate_password_length修改mysql参数配置 :set global validate_password_policy=0;
关闭mysql:systemctl stop mysqld.service
重启mysql:systemctl restart mysqld.service
设置mysql服务开机自启动:systemctl enable mysqld.service
停止mysql服务开机自启动:systemctl disable mysqld.service
防火墙打开3306端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent
重启防火墙:firewall-cmd --reload
查看安装的mysql:rpm -qa | grep -i mysql
卸载mysql:yum -y remove mysql-community-common-5.7.26-1.el7.x86_64(依次卸载上图中的软件)
whereis mysql查询之前安装生成的目录,分别移除。