文档:mysql安装.md
链接:http://note.youdao.com/noteshare?id=b8ed8610929a139137d2ec4f908ed5db&sub=WEBc654e6d986bb642ff8bbe6ba8c16951b
MySQL5.7 安装步骤
-
下载并安装MySQL官方的 Yum Repository
1.下载安装包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.安装Yum Repository(此步骤可以不安装,因为之后每次执行yum都会自动更新)
yum -y install mysql57-community-release-el7-10.noarch.rpm
此命令写在上个命令安装的插件
yum -y remove mysql57-community-release-el7-10.noarch
3.安装mysql服务
yum -y install mysql-community-server
这步可能会花些时间,安装完成后就会覆盖掉之前的mariadb。
-
Myql相关设置
1.启动mysql
systemctl start mysqld.service
2.查看mysql运行状态
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: "active (running)" since 六 2020-05-02 21:56:46 CST; 16s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2767 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 2669 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 2771 (mysqld)
CGroup: /system.slice/mysqld.service
└─2771 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
5月 02 21:56:41 iZrj95jxkiivfwdyn5n5ixZ systemd[1]: Starting MySQL Server...
5月 02 21:56:46 iZrj95jxkiivfwdyn5n5ixZ systemd[1]: Started MySQL Server.
看到active(runting)证明mysql已经运行,但是连接mysql还是需要密码,此时我们通过以下命令找出mysql密码
grep "password" /var/log/mysqld.log
3.输入以下命令连接数据库
mysql -uroot -p
4.连接到mysql,必须修改默认密码才可以操作数据库
先执行一下两个命令,修改密码校验规则之后可以设置简单密码,如不执行下面命令,密码过于简单会报错。
1.set global validate_password_policy=0;
2.set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
5.修改mysql用户远程连接
use mysql;
// 查询myql用户信息
select user,host from user;
// 修改myqsl用户为远程连接
update user set host="%" where user="root";
// 使本次修改立即生效
flush privileges;
-
Mysql相关命令
systemctl restart mysqld.service
systemctl start mysqld.service
systemctl stop mysqld.service
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Linux 搭建mysql - Python技术站