又又又又..Linux装MySQL。
删除原有的MySQL
查看安装的mysql信息:rpm -qa|grep -i mysql
删除mysql相关服务:rpm -e --nodeps
查询mysql遗留文件和依赖信息:find / -name mysql
手动删除mysql配置文件:rm -rf /etc/my.cnf
相关命令
启动:systemctl start mysqld.service
状态查看:systemctl status mysqld.service
设置开机自启:systemctl enable mysqld.service
重启mysql:service mysqld restart
关闭命令:systemctl stop mysqld.service
下载mysql80
yum仓库文件:wget http://repo.mysql.com/mysql80-community-release-el7-10.noarch.rpm
安装
sudo yum install mysql80-community-release-el7-10.noarch.rpm
安装mysql
cd /opt
sudo yum install mysql-community-server
启动mysql
sudo service mysqld start
查看mysql是否启动
ps -ef | grep mysql
获取mysql 的初始密码
sudo grep 'temporary password' /var/log/mysqld.log
)hj_elVoE7iX就是初始密码
登陆mysql
mysql -uroot -p
输入初始化密码
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'lyon@2023';
报错
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements。自定义密码比较简单,不符合密码策略。
修改
ALTER USER 'root'@'localhost' IDENTIFIED BY 'LYon@2023';
查看密码策略
SHOW VARIABLES LIKE 'validate_password%';
设置密码策略
set global validate_password.policy=LOW;
设置密码长度
set global validate_password.length=6;
flush privileges;
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.02 sec)