1.配置MySQL的repo源
# wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
# rpm -ivh mysql57-community-release-el7-7.noarch.rpm
2.安装
# yum install mysql-server
# yum install mysql-devel
# yum install mysql
安装完检查软件命令:
rpm -qa|grep -i mysql
3.启动与关闭MySQL服务
# service mysqld status 查看mysql当前的状态
# service mysqld stop 停止mysql
# service mysqld restart 重启mysq
l# service mysqld start 启动mysql
4.修改密码
1.查看日志/var/log/mysqld.log文件,找到关键字A temporary password,最后的字符串就是临时密码,使用临时密码登录
2.设置新密码命令:
SET PASSWORD = PASSWORD('Qwe123&%%');
本机登录命令为 mysql -u root -p
新密码必须包含英文字母大小写,数字与特殊符号,至少八位
5.授予远程连接权限
mysql> use mysql;
Database changed
mysql> grant all privileges on *.* to root@'%' identified by "登录密码";
Query OK, 0 rows affected (0.00 sec)
远程连接命令:mysql -h ip -P 3306 -u root -p
网友评论