CentOS7 使用 yum 安装 mysql 遇到的一个问题

来源:互联网 发布:maxwell软件渲染 编辑:程序博客网 时间:2024/06/01 08:26

在CentOS7 安装时,默认的选择数据库服务,然后又默认的使用了yum安装,却不知道从centos7开始,已经放弃了mysql,开始使用Mariadb(开源的 mysql分支)

所以别傻了~ 还...   systemctl start mysqld.service .... 

根本就提示:

服务不存在。

然后还  mysql -uroot -p ....

结果还提示:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

哈哈,是不是很恼火....还在网上查 什么这个,那个改配置文件,都是坑人的...

直接上干货:

[root@heavensvr etc]# systemctl start mariadb.service
[root@heavensvr etc]# systemctl enable mariadb.service

是不是发现,根本就是正常反应。。。

这时候,你只需执行这个...

[root@heavensvr etc]# mysql_secure_installation其妙的事情发生了...

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user.  If you've just installed MariaDB, andyou 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 MariaDBroot user without the proper authorisation.Set root password? [Y/n] y      --这里设置密码New password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y   --这里去掉匿名用户 ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] N --这里关闭远程root访问,需要就选N ... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] N   --是否删除测试库及访问 - Dropping test database... ... Success! - Removing privileges on test database...  ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y  --是否重新加载权限表 ... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!到这里,你就可以正常访问了,Look....[root@heavensvr etc]# mysql -uroot -pxxxxxxxmimaWelcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 15Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> 

原创粉丝点击