云服务器搭建二:linux安装MySQL数据库

2019-07-22  本文已影响0人  蜻蜓队长家长

yum安装MySQL

https://dev.mysql.com/downloads/repo/yum/

#下载
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

# 安装 mysql 源
yum localinstall mysql57-community-release-el7-11.noarch.rpm

#检查是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
检查安装-安装成功
#使用 yum install 命令安装
yum install mysql-community-server

#启动 MySQL 服务 (systemctl start mysqld)、停止MySQL为 systemctl stop mysqld
systemctl start mysqld

#查看状态(systemctl status mysqld)
systemctl status mysqld
查看状态-启动成功
systemctl enable mysqld
systemctl daemon-reload
grep 'temporary password' /var/log/mysqld.log
查看临时密码
 mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySQLpwd2019!';

后续如果需要修改请使用update set语句

use mysql; 
update user set authentication_string=PASSWORD('Mysql2019!') where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'zhangsan'@'%' IDENTIFIED BY 'Zhangsan2019!' WITH GRANT OPTION;

默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须添加一个允许远程连接的帐户。

也可以直接修改 root 为允许远程连接 (不推荐)

use mysql;
UPDATE user SET Host='%' WHERE User='root';
flush privileges;
上一篇下一篇

猜你喜欢

热点阅读