linux快速安装mysql
-
安装之前检测系统是否有自带的MySQL
#检查是否安装过MySQL rpm -qa | grep mysql #检查是否存在 mariadb 数据库(内置的MySQL数据库),有则强制删除 rpm -qa | grep mariadb #强制删除 rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 #强制删除 rpm -e --nodeps mariadb-5.5.68-1.el7.x86_64
-
导入密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
-
配置MySQL的yum仓库
rpm -Uvh http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
-
使用yum安装mysql
yum -y install mysql-community-server
-
启动mysql
systemctl start mysqld
-
查看MySQL状态
systemctl status mysqld
-
设置为开机自启
systemctl enable mysqld
-
获取MySQL初始密码
cat /var/log/mysqld.log |grep "temporary password"
-
登录mysql数据库
mysql -u root -p
-
修改root用户命令(密码有要求 不低于8位,有大小写,有特殊字符)
alter user 'root'@'localhost' identified by 'rootRoot123.';
-
设置简单密码(把校验策略改成低/把密码校验长度改低一点
set global validate_password_policy=LOW; set global validate_password_length=4; alter user 'root'@'localhost' identified by '123456';
-
设置远程访问文章来源:https://www.toymoban.com/news/detail-624709.html
grant all privileges on *.* to 'root' @'%' identified by '123456'; flush privileges;
-
卸载文章来源地址https://www.toymoban.com/news/detail-624709.html
#强制删除已安装MySQL rpm -e --nodeps mysql-community-libs rpm -e --nodeps mysql-community-client rpm -e --nodeps mysql-community-server rpm -e --nodeps mysql57-community-release rpm -e --nodeps mysql-community-common rpm -qa|grep mysql #查找所有MySQL目录并删除:find / -name mysql find / -name mysql find: ‘/proc/35432’: 没有那个文件或目录 #/var/lib/mysql #/var/lib/mysql/mysql #/usr/lib64/mysql #/usr/share/mysql rm -rf /var/lib/mysql rm -rf /usr/share/mysql rm -rf /usr/lib64/mysql
删除my.cnf:rm -f /etc/my.cnf
rm -f /etc/my.cnf
到了这里,关于linux快速安装mysql的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!