Centos7安装MySQL5.7 的简单步骤教程
一、进入终端,开始执行
1、下载
2、rpm -ivh mysql57-community-release-el7-11.noarch.rpm
3、yum install -y mysql-community-server
4、启动mysql服务才有下面的步骤:systemct? start? mysqld.service
就三步安装完毕。
二、修改密码.
1、先获取默认密码:sudo grep 'temporary password' /var/log/mysqld.log;输入后便可以获取到默认密码,记下,有用。
2、进行登录:mysql -uroot -p,接着输入上一步的密码,成功进入。
3、修改密码:alter user 'root'@'localhost' identified by 'root_123456';注意:密码有要求的:this will require that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.
4、执行:flush privileges;刷新一下。
三、启动和结束命令:
1、启动命令: sudo systemctl start mysqld.service
2、停止命令: sudo systemctl stop mysqld.service
3、查看状态:sudo systemctl status mysqld.service
四、设置外网可以访问:
1、只授权192.168.1.101才能连接:grant all privileges on *.* to 'root'@'192.168.1.101' identified by 'root_123456' with grant option;flush privileges;
2、设置都可以连接:grant all privileges on *.* to? 'root'@'%' identified by 'root_123456' with grant option;flush privileges;
五、设置编码:
1、通过:whereis my.cnf找到/etc/my.cnf,然后编辑:vim /etc/my.cnf加入:character-set-server=utf8,保存。
六:设置开机启动:
1、设置开机启动:在/etc/rc.d/rc.local下加入:sudo systemctl start mysqld.service就行(不过我重启了,它是自动启动的。)
上一篇: asp.net core在iis上发布
下一篇: 存钱罐里少了200块钱