最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

Centos7 安装MySql Mariadb

LINX-SQL ajiang-tuzi 11097浏览

注: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)]> 

转载请注明:(●--●) Hello.My Weicot » Centos7 安装MySql Mariadb

蜀ICP备15020253号-1