腾讯云CentOS 7.5安装MySQL

自古美人都是妖i 提交于 2021-02-04 10:47:53

<div style="font-size:14px">dbq我刚刚装好MySQL就不放图啦</div> <div style="font-size:14px; font-weight:bold">1.下载安装包</div> <div style="font-size:14px">wget http://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm</div> <div style="font-size:14px; font-weight:bold">2.安装下载下来的rpm包</div> <div style="font-size:14px">yum localinstall mysql57-community-release-el6-10.noarch.rpm</div> <div style="font-size:14px; font-weight:bold">3.(可选)查看可用的安装包</div> <div style="font-size:14px">yum repolist enabled|grep mysql</div> <div style="font-size:14px; font-weight:bold">4.若之前在服务器已经装过了nginx可跳过,否则请安装</div> <div style="font-size:14px">yum install gcc-c++</div> <div style="font-size:14px; font-weight:bold">5.安装mysql</div> <div style="font-size:14px">yum install -y mysql-community-server</div> <div style="font-size:14px">(此时会报错,解决办法是通过WinSCP(下载地址:<a href='https://winscp.net/eng/docs/lang:chs'>click here</a>)修改/etc/yum.repos.d/mysql-community.repo 源文件如下:</div> ```c [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ``` <div style="font-size:14px">修改后保存再次执行 yum install -y mysql-community-server</div> <div style="font-size:14px; font-weight:bold">6.启动mysql</div> <div style="font-size:14px">/bin/systemctl start mysqld.service</div> <div style="font-size:14px; font-weight:bold">7.修改密码</div> <div style="font-size:14px">通过WinSCP找到etc目录下的my.cnf文件,直接在[mysqld]下添加"skip-grant-tables"(双引号不用加,作用是登录时跳过登录认证,空也可登录)保存</div> <div style="font-size:14px"># mysql -uroot -p 进入mysql密码为任意数</div> <p style="font-size:14px"> mysql>use mysql;<br/> mysql>update user set authentication_string=password(“newpassword“) where user=”root”;<br/> mysql>flush privileges;</p> <div style="font-size:14px;color:red">注:newpassword最好特殊符号、数字、大小写字母都有,这样后面不容易报1820、1819之类的error</div> <div style="font-size:14px">修改完退出 mysql>quit</div> <div style="font-size:14px">删除之前在my.cnf文件中添加的"skip-grant-tables"</div> <div style="font-size:14px; font-weight:bold">8.重启mysql</div> <div style="font-size:14px">/bin/systemctl restart mysqld.service</div> <div style="font-size:14px; font-weight:bold">9. 进入mysql</div> <div style="font-size:14px">mysql -uroot -p</div> <div style="font-size:14px; font-weight:bold">10.建数据库建表</div> <div style="font-size:14px">详见:<a href='https://blog.csdn.net/longampp520/article/details/71516985/'>click here</a></div>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!