Linux
Centos6.8下安装mysql
本篇文章下将为大家讲解如何在Centos6.8下安装mysql
本篇文章下将为大家讲解如何在Centos6.8下安装mysql,博主将之前安装mysql的过程记录分享给大家,避免大家走一些坑。
1、yum安装mysql
yum install mysql mysql-server
2、根据提示完成mysql并启动
/etc/init.d/mysqld start
3、设置mysql为开机服务
chkconfig mysqld on
4、接下来就是为mysql的root账号设置密码(默认的密码是空)
mysql_secure_installation
输入以上命令并回车,如果你是新安装的mysql则会出现以下提示
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 willbe blank, so you should just press enter here Enter current password for root (enter for none):
因为你是新安装,默认密码为空,直接按enter键就可以。然后设置新的密码,输入Y即可。
输入两次密码确认(一定要记住密码哦!后面设置其他用户还需要用的密码进入MySQL,创建用户等操作)
再接着就是会有若干个提示:
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 aproduction environment.Remove anonymous users? [Y/n] y
MySQL会默认创建一个匿名用户,问你是否删除,一般输入Y删除掉。但博主选择的是输入N,不删除。
接着出现以下提示:
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] y
root用户默认只能访问localhost,以防有人猜密码,是否禁止root登陆,一般选择n。
接着便会提示你是否新建一个test库,出现以下提示:
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]
mysql默认创建一个名为test的数据库,这个库任何人都可以访问,是否删除掉,一般不删除。然后便会出现以下提示:
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.Reload privilege tables now? [Y/n]
意思是上面的修改是否马上生效:输入Y。便会出现以下提示:
Thanks for using MySQL!
那么恭喜你,我们安装mysql并成功的进行密码的修改了,然后便重新启动mysql
/etc/init.d/mysqld restart
0条评论