centos7 mysql安装
1.下载命令:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2.然后进行yun源的安装
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
3.安装完成后,就可以使用yum命令安装mysql了:
yum -y install mysql-server
4.启动mysql:
systemctl start mysqld
5.查看mysql状态:
systemctl status mysqld
6.获取mysql的临时密码:
grep 'temporary password' /var/log/mysqld.log
7.登录mysql:(密码为上一步骤获取的临时密码)
mysql -u root -p #登录成功后,做任何操作都会被要求先修改密码
8.修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '-520Lemon-';
设置远程连接
username:自己数据库用户名
password:自己数据库登录密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)