您的位置:首页 > 运维架构 > Linux

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

2017-07-21 03:55 811 查看
在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 current
password for the root user.  If you've just installed MariaDB, 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 MariaDB
root 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 anyone
to log into MariaDB 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] y   --这里去掉匿名用户
... 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] N --这里关闭远程root访问,需要就选N
... Success!

By default, MariaDB 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] N   --是否删除测试库及访问
- 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] y  --是否重新加载权限表
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

到这里,你就可以正常访问了,Look....
[root@heavensvr etc]# mysql -uroot -pxxxxxxxmima
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (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)]>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: