centos7 win安装mysql_Centos7 安装MySql Mariadb

注:centos7系统,安装mysql默认的是mariadb

首先运行

yum install mysql mysql-server

不过我运行后 开启mysql 的时候总是报这个错误

[root@ajaing-tuzi ~]# service mysql start

Redirecting to /bin/systemctl start mysql.service

Failed to start mysql.service: Unit mysql.service failed to load: No such file or directory.

[root@ajaing-tuzi ~]# /etc/init.d/mysql status

-bash: /etc/init.d/mysql: 没有那个文件或目录

[root@ajaing-tuzi ~]# systemctl enable mysql.service

Failed to execute operation: Access denied

[root@ajaing-tuzi ~]# systemctl enable mysql.service

Failed to execute operation: Access denied

[root@ajaing-tuzi ~]# mysql

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

[root@ajaing-tuzi ~]# cd var/ib/mysql

我怀疑肯定是少了什么东西

确认是否已经安装了所有的mariadb所需要的库

[root@ajaing-tuzi ~]# sudo yum -y install mariadb*

接下来是最重要的(下面的两条要用root权限)

systemctl start mariadb.service

systemctl enable mariadb.service

不过我在运行第一条命令的时候 暴了个错

[root@ajaing-tuzi etc]# systemctl enable mariadb.service

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

[root@ajaing-tuzi etc]# journalctl -xe

If you believe that mysqld should be allowed create access on the mysql.sock sock_file by default.

Then you should report this as a bug.

You can generate a local policy module to allow this access.

Do

allow this access for now by executing:

# grep mysqld /var/log/audit/audit.log | audit2allow -M mypol

# semodule -i mypol.pp

1月 17 20:09:22 ajaing-tuzi.servicr2 dbus-daemon[619]: 'list' object has no attribute 'split'

1月 17 20:09:23 ajaing-tuzi.servicr2 systemd[1]: mariadb.service: control process exited, code=exited status=1

1月 17 20:09:23 ajaing-tuzi.servicr2 systemd[1]: Failed to start MariaDB database server.

-- Subject: Unit mariadb.service has failed

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit mariadb.service has failed.

--

-- The result is failed.

1月 17 20:09:23 ajaing-tuzi.servicr2 systemd[1]: Unit mariadb.service entered failed state.

1月 17 20:09:23 ajaing-tuzi.servicr2 systemd[1]: mariadb.service failed.

1月 17 20:09:23 ajaing-tuzi.servicr2 polkitd[872]: Unregistered Authentication Agent for unix-process:5265:1558350 (system bus name :1.98, object path /org/freedesktop/PolicyKit1/Authenticati

1月 17 20:09:29 ajaing-tuzi.servicr2 polkitd[872]: Registered Authentication Agent for unix-process:5564:1560573 (system bus name :1.102 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object

1月 17 20:09:29 ajaing-tuzi.servicr2 systemd[1]: Reloading.

1月 17 20:09:29 ajaing-tuzi.servicr2 systemd[1]: [/usr/lib/systemd/system/initial-setup-graphical.service:14] Support for option SysVStartPriority= has been removed and it is ignored

1月 17 20:09:29 ajaing-tuzi.servicr2 systemd[1]: [/usr/lib/systemd/system/initial-setup-text.service:21] Support for option SysVStartPriority= has been removed and it is ignored

1月 17 20:09:29 ajaing-tuzi.servicr2 systemd[1]: Configuration file /usr/lib/systemd/system/auditd.service is marked world-inaccessible. This has no effect as configuration data is accessible

1月 17 20:09:29 ajaing-tuzi.servicr2 systemd[1]: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Please remove executable permission bits. Proceeding anyway.

1月 17 20:09:29 ajaing-tuzi.servicr2 systemd[1]: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executable. Please remove executable permission bits. Proceeding a

1月 17 20:09:29 ajaing-tuzi.servicr2 polkitd[872]: Unregistered Authentication Agent for unix-process:5564:1560573 (system bus name :1.102, object path /org/freedesktop/PolicyKit1/Authenticat

lines 3248-3277/3277 (END)

过后 我检查了下配置文件中的目录 修改后成功启动

[root@ajaing-tuzi etc]# vim my.cnf

[root@ajaing-tuzi etc]# systemctl start mariadb.service

[root@ajaing-tuzi etc]# systemctl enable mariadb.service

[root@ajaing-tuzi etc]# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 2

Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.00 sec)

MariaDB [(none)]>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值