在阿里云服务器上安装mysql及重置密码
参考链接:https://www.cnblogs.com/ljysy/p/10324854.html
下载与安装MySQL:
这里采用Yum管理好了各种rpm包的依赖,能够从指定的服务器自动下载RPM包并且安装,所以在安装完成后必须要卸掉,否则会自动更新。
1.安装MySQL官方的yum repository
[ ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.下载rpm包
[ ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
3.安装MySQL服务
[ ~]# yum -y install mysql-community-server
最后会出现个complete!
4.启动MySQL服务
[ ~]# systemctl start mysqld.service
看到类似下面的界面,或者以Starting MySqL server.. started MysqlServer..结尾的就成功启动了
还有几个关于MySQL常用的命令:
重启:systemctl restart mysqld.service 停止:systemctl stop mysqld.service 查看状态:systemctl status mysqld.service
关于登录MySQL:
登录命令:
[ ~]# mysql -u root -p
意思就是用root用户登录,然后准备输入密码
初次登陆先 查看MySql默认密码
[ ~]# grep ‘temporary password‘ /var/log/mysqld.log
修改数据库密码
由于set password for root @localhost=password(‘passwd‘); 可能会报错
MySQL 5.7 中 Your password does not satisfy the current policy requirements.
问题
set global validate_password_policy=0;
MySQL 5.7 中 Your password does not satisfy the current policy requirements.
问题
set global validate_password_policy=0;
set global validate_password_length=4;
上面两个命令搞定 开始设置自己的密码:
set password for root @localhost=password(‘passwd‘);
set password for root @localhost=password(‘passwd‘);
一些常用命令
# 重启MySql服务 [ ~]# service mysqld restart # 查看MySql版本 [ ~]# yum repolist all | grep mysql # 查看当前的启动的 MySQL 版本 [ ~]# yum repolist enabled | grep mysql # 通过Yum来安装MySQL,会自动处理MySQL与其他组件的依赖关系 [ ~]# yum install mysql-community-server # 查看MySQL安装目录 [ ~]# whereis mysql # 启动MySQL服务 [ ~]# systemctl start mysqld # 查看MySQL服务状态 [ ~]# systemctl status mysqld # 关闭MySQL服务 [ ~]# systemctl stop mysqld # 测试MySQL是否安装成功 [ ~]# mysql # 查看MySql默认密码 [ ~]# grep ‘temporary password‘ /var/log/mysqld.log # 查看所有数据库 mysql>show databases; # 退出登录数据库 mysql>exit; # 查看所有数据库用户 mysql>SELECT DISTINCT CONCAT(‘User: ‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user
相关推荐
emmm00 2020-11-17
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
疯狂老司机 2020-09-08
CoderToy 2020-11-16
ribavnu 2020-11-16
bianruifeng 2020-11-16