[root@hz-build-cloud-cbts02-okqvd ~]# service mysql start
Redirecting to /bin/systemctl start mysql.service
Failed to start mysql.service: Unit not found.
[root@hz-build-cloud-cbts02-okqvd ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@hz-build-cloud-cbts02-okqvd ~]# ls /var/lib/mysql/
[root@hz-build-cloud-cbts02-okqvd ~]# vi /etc/my.cnf
[root@hz-build-cloud-cbts02-okqvd ~]# ls /var/lib/mysql/my.cnf
ls: cannot access /var/lib/mysql/my.cnf: No such file or directory
[root@hz-build-cloud-cbts02-okqvd ~]# ls /etc/init.d/mysql
ls: cannot access /etc/init.d/mysql: No such file or directory
尝试卸载mysql-server,安装mariadb, 启动mariadb服务即可。
[root@hz-build-cloud-cbts02-okqvd ~]# yum remove mysql-server
[root@hz-build-cloud-cbts02-okqvd ~]# yum erase mysql-community-common.x86_64
[root@hz-build-cloud-cbts02-okqvd ~]# yum list installed |grep mysql
mysql57-community-release.noarch el7-9 installed
[root@hz-build-cloud-cbts02-okqvd ~]# yum erase mysql57-community-release.noarch
[root@hz-build-cloud-cbts02-okqvd ~]# yum install mariadb mariadb-libs mariadb-server -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Package 3:mariadb-10.1.20-2.el7.x86_64 already installed and latest version
Package 3:mariadb-libs-10.1.20-2.el7.x86_64 already installed and latest version
Package 3:mariadb-server-10.1.20-2.el7.x86_64 already installed and latest version
Nothing to do
[root@hz-build-cloud-cbts02-okqvd ~]# systemctl start mariadb.service
[root@hz-build-cloud-cbts02-okqvd ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@hz-build-cloud-cbts02-okqvd ~]#
[root@hz-build-cloud-cbts02-okqvd ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.20-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)]>
mysql安装成功后,启用django服务,报错如下,考虑安装MySQL-python模块:
File "/usr/lib64/python3.4/site-packages/django/db/models/options.py", line 205, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/usr/lib64/python3.4/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/lib64/python3.4/site-packages/django/db/utils.py", line 202, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/lib64/python3.4/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/