注:该安装步骤转载于CSDN,下方配置为原创
按照图片安装并初始化完成MySQL等操作后进行;
安装对于rpm包集合
1-查看安装情况(有4个路径)
whereis mysql
2-查看服务状态
systemctl status mysql
3-初始化数据库
mysqld --initialize --console
4-目录授权
chown -R mysql:mysql /var/lib/mysql
5-启停mysql服务
systemctl start mysqld
systemctl stop mysqld
systemctl restart mysqld
systemctl enable mysqld (开机自启)
6-获取初始化的密码
grep ‘temporary password’ /var/log/mysqld.log
=====================================================================================================================
登录mysql数据库的root账户
mysql -u root -p’密码’
1.修改密码(新版本需要先重置密码才能继续操作)
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘Root_123’;
2.退出然后用新密码登录
mysql -u root -p’Root_123’;
3.登录后在sqlplus状态下安装密码策略插件
install plugin validate_password soname ‘validate_password.so’;
4.查看安装的密码策略插件是否生效
select plugin_name, plugin_status from information_schema.plugins where plugin_name like ‘validate%’;
5.查看密码策强度略(高版本是xxx.xxx 低版本是xxx_xxx)
SHOW VARIABLES LIKE ‘validate_password%’;
6.修改密码策强度略
set global validate_password.policy=0;
set global validate_password.length=4;
7.指定用户-密码过期禁用(高版本默认不会过期好像)
ALTER USER ‘用户名’@‘localhost’ PASSWORD EXPIRE NEVER;
8.查看mysql下的用户以及密码限制
select user,host,password_expired,password_last_changed,password_lifetime from mysql.user;
=======================================================================================================================
开放 root 账户远程登录
1-登录MySQL
mysql -u root -p’密码’
2-进入数据库
use mysql
3-修改user表
update user set host=‘%’ where user=‘root’;
mysql 5.7 及之前老版本,执行这行sql即可
GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ IDENTIFIED BY ‘你的密码’ WITH GRANT OPTION;
4-重载授权表
FLUSH PRIVILEGES;
5-退出
exit
6-重启
systemctl restart mysqld