centOS安装mysql5.7详细教程
本⽂为⼤家分享了centOS下安装mysql5.7详细步骤,供⼤家参考,具体内容如下
第⼀步:
第⼀句检测系统是否⾃带安装mysql,若有执⾏第⼆句删除系统⾃带的mysql及其依赖。
yum list installed | grep mysql
yum -y remove mysql-libs.x86_64
第⼆步:
mysql下载后的初次使用给CentOS添加rpm源,并且选择较新的源,下⾯代码逐句执⾏
sql/arch.rpm
yum arch.rpm
yum repolist all | grep mysql
yum-config-manager --disable mysql55-community
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community-dmr
yum repolist enabled | grep mysql
第三步:
安装mysql 服务器
yum install mysql-community-server
第四步:
service mysqld start
第五步:
查看mysql是否⾃启动,并且设置开启⾃启动
chkconfig --list | grep mysqld
chkconfig mysqld on
第六步:
这⼀步很重要
不知道从mysql哪个版本开始,mysql的root默认密码就不为空了,在安装的过程中默认密码保存在安装⽇志中了。我们要通过安装⽇志到默认密码,⽤默认密码登陆mysql成功后会强⾏让你修改密码,修改的密码还要够复杂(复合mysql默认的密码策略)才能修改成功,⼀般带⼤⼩写字母特殊字符和数字超过8个字符就可以。
⾸先到安装⽇志
find / -name mysqld.log
然后发现该⽇志⽂件路径在 /var/log/mysqld.log。然后⽤下⾯命令打开,按‘i'键上翻
vim /var/log/mysqld.log
上图红⾊地⽅就是root密码所在地
第七步:
mysql安全设置
mysql_secure_installation
输⼊上⾯命令进⾏下⾯步骤
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):<–初次运⾏,输⼊刚刚到的初始密码,会强制你先修改密码才能进⾏下去
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] <– 是否设置root⽤户密码,输⼊y并回车或直接回车
New password: <– 设置root⽤户的密码
Re-enter new password: <– 再输⼊⼀次你设置的密码
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] <– 是否删除匿名⽤户,⽣产环境建议删除,所以直接回车
… Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <–是否禁⽌root远程登录,根据⾃⼰的需求选择Y/n并回车,建议禁⽌
… Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] <– 是否删除test数据库,直接回车
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,直接回车
… Success!
Cleaning up…
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@server1 ~]#
第⼋步:
可选步骤,原来Linux下的MySQL默认是区分表名⼤⼩写的,通过如下设置,可以让MySQL不区分表名⼤⼩写:
1、⽤root登录,修改 /etc/myf;
2、在[mysqld]节点下,加⼊⼀⾏: lower_case_table_names=1
3、重启MySQL即可; service mysqld restart
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。