34

So... likely I'm an idiot, but I'm stuck. I just set up a CentOS 7 on Digial Ocean and I can't seem to get the MariaDB/MySQL server running.

Some output

[root@hostname ~]# yum list installed |grep maria
mariadb.x86_64                        1:5.5.37-1.el7_0                @updates  
mariadb-libs.x86_64                   1:5.5.37-1.el7_0                @updates  
mariadb-server.x86_64                 1:5.5.37-1.el7_0                @updates  

So it's installed, can we at least see the client?

[root@hostname ~]# which mysql
/bin/mysql

Let's try and start the server, just for fun

[root@hostname ~]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
[root@hostname ~]# mysqld
-bash: mysqld: command not found
[root@hostname ~]# mysql.server start
-bash: mysql.server: command not found
[root@hostname ~]# 

And this is where I get lost. Looking at what is actually installed, there is no server/daemon

[root@hostname ~]# ls -la /bin/my*
-rwxr-xr-x 1 root root 3419136 Jun 24 10:27 /bin/myisamchk
-rwxr-xr-x 1 root root 3290760 Jun 24 10:27 /bin/myisam_ftdump
-rwxr-xr-x 1 root root 3277032 Jun 24 10:27 /bin/myisamlog
-rwxr-xr-x 1 root root 3320200 Jun 24 10:27 /bin/myisampack
-rwxr-xr-x 1 root root 2914904 Jun 24 10:27 /bin/my_print_defaults
-rwxr-xr-x 1 root root 3533016 Jun 24 10:27 /bin/mysql
-rwxr-xr-x 1 root root  111587 Jun 24 10:24 /bin/mysqlaccess
-rwxr-xr-x 1 root root 3089712 Jun 24 10:27 /bin/mysqladmin
-rwxr-xr-x 1 root root 3253112 Jun 24 10:27 /bin/mysqlbinlog
lrwxrwxrwx 1 root root      26 Sep  8 03:06 /bin/mysqlbug -> /etc/alternatives/mysqlbug
-rwxr-xr-x 1 root root 3090832 Jun 24 10:27 /bin/mysqlcheck
-rwxr-xr-x 1 root root    4247 Jun 24 10:24 /bin/mysql_convert_table_format
-rwxr-xr-x 1 root root   24558 Jun 24 10:24 /bin/mysqld_multi
-rwxr-xr-x 1 root root   27313 Jun 24 10:24 /bin/mysqld_safe
-rwxr-xr-x 1 root root 3173968 Jun 24 10:27 /bin/mysqldump
-rwxr-xr-x 1 root root    7913 Jun 24 10:24 /bin/mysqldumpslow
-rwxr-xr-x 1 root root    3315 Jun 24 10:24 /bin/mysql_find_rows
-rwxr-xr-x 1 root root    1261 Jun 24 10:24 /bin/mysql_fix_extensions
-rwxr-xr-x 1 root root   34826 Jun 24 10:24 /bin/mysqlhotcopy
-rwxr-xr-x 1 root root 3082072 Jun 24 10:27 /bin/mysqlimport
-rwxr-xr-x 1 root root   16204 Jun 24 10:24 /bin/mysql_install_db
-rwxr-xr-x 1 root root 2923136 Jun 24 10:27 /bin/mysql_plugin
-rwxr-xr-x 1 root root   11578 Jun 24 10:24 /bin/mysql_secure_installation
-rwxr-xr-x 1 root root   17473 Jun 24 10:24 /bin/mysql_setpermission
-rwxr-xr-x 1 root root 3084760 Jun 24 10:27 /bin/mysqlshow
-rwxr-xr-x 1 root root 3104240 Jun 24 10:27 /bin/mysqlslap
-rwxr-xr-x 1 root root 3442464 Jun 24 10:27 /bin/mysqltest
-rwxr-xr-x 1 root root 2918416 Jun 24 10:27 /bin/mysql_tzinfo_to_sql
-rwxr-xr-x 1 root root 2995400 Jun 24 10:27 /bin/mysql_upgrade
-rwxr-xr-x 1 root root 2913960 Jun 24 10:27 /bin/mysql_waitpid
-rwxr-xr-x 1 root root    3888 Jun 24 10:24 /bin/mysql_zap

Anyone care to point out what I'm doing wrong here?

44

Should anyone stumble across this, i found the solution here: https://ask.fedoraproject.org/en/question/43459/how-to-start-mysql-mysql-isnt-starting/

Repost below


To start MariaDB on Fedora 20, execute the following command:

systemctl start mariadb.service

To autostart MariaDB on Fedora 20, execute the following command:

systemctl enable mariadb.service

After you started MariaDB (do this only once), execute the following command:

/usr/bin/mysql_secure_installation
| improve this answer | |
  • 4
    Trying sudo systemctl start mariadb, I get Failed to start mariadb.service: Unit mariadb.service failed to load: No such file or directory. – donquixote Jan 13 '15 at 4:58
  • 2
    sudo systemctl enable mysqld before sudo systemctl start mysqld did the trick, it seems. – donquixote Jan 13 '15 at 5:02
  • thanks @donquixote I've never encountered that behaviour before (needing to enable before starting) with systemd. it looks like mysqld.service can be successfully disabled after starting and not stop the service. I want to explicitly start and stop the mysql service and not have it run automatically on boot. – lsh May 5 '16 at 11:20
15

When you run:

yum install mysql

command by default it installs MariaDB not MySQL.

So try the following command:

yum list installed | grep mariadb

if mariadb-server is missing try this following command:

yum install mariadb-server

it installs the server package then start the service:

systemctl start mariadb

or:

service mariadb start

My issue was solved in this way.

| improve this answer | |
  • This seems to be the correct answer as of late 2016. When installing mysql on CentOS it will install maria db, but it may not install the server (which is weird) This did the trick. – Craig Jacobs Mar 16 '17 at 19:26
  • Thorough and simple explanation, and it even worked! I am on the new Amazon Linux. Thanks! – musicin3d Jan 9 '19 at 19:34
3

The service name is mariadb so you can start it using:

service mariadb start

Stop it using:

service mariadb stop

And restart it using:

service mariadb restart
| improve this answer | |
  • 3
    CentOS 7 is using systemd, so you should use the appropriate systemctl commands instead of the old service commands. – Sven Feb 7 '15 at 11:37
2

See if mysqld is under /usr/libexec/ directory. At least with CentOS 6.5 the usual MySQL installs the server itself there.

Also see the output from systemctl list-units to see the name for you MariaDB server.

| improve this answer | |
  • mysqld is indeed present in the /usr/libexec/ directory. However I don't see anything about MariaDB (or MySQL) in the output of the systemctl list-units command – danneth Sep 8 '14 at 8:32
2

I had a similar problem trying to start the mariadb service

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

I figured the issue was in non-matching yum packages - some were installed from the special mariadb repo and others from the centos official repo. Thus I had to drop the custom yum repo entry, delete MariaDB packages and install mariadb-server anew, then the service would start without problem.

| improve this answer | |
  • The output states @updates as the repo, so that doesn't seem to be the case here. This may still be useful to someone else, so thank you for sharing :-) – jornane Aug 13 '15 at 10:55
0

@OP Please pick a best answer; @Moderator please lock question;

Ran into this same issue, tried the other steps mentioned to no avail; what my problem was being logged in as root/sudo su, after exiting su and running $ systemctl status mariadb I recieved

mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

I then ran $ sudo systemctl enable mariadb recieving

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

Then starting mariadb with $ sudo systemctl start mariadb - No error/message so it should be good, but no harm in checking $ systemctl status mariadb

mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2018-10-17 10:07:00 CDT; 5min ago
  Process: 18093 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 18000 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 18092 (mysqld_safe)
    Tasks: 20
   CGroup: /system.slice/mariadb.service
           ├─18092 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─18261 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock

Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: MySQL manual for more instructions.
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: Please report any problems at http://mariadb.org/jira
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: The latest information about MariaDB is available at http://mariadb.org/.
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: You can find additional information about the MySQL part at:
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: http://dev.mysql.com
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: Consider joining MariaDB's strong and vibrant community:
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: https://mariadb.org/get-involved/
Oct 17 10:06:58 centos-7.shared mysqld_safe[18092]: 181017 10:06:58 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Oct 17 10:06:58 centos-7.shared mysqld_safe[18092]: 181017 10:06:58 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Oct 17 10:07:00 centos-7.shared systemd[1]: Started MariaDB database server.
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.