Install mysql client NOT server on Centos7

8,591

Your mysql client is currently trying to connect to a server running on the local machine (which doesn't exist).

You need to specify, on the command line, the connection string (including user, hostname, port etc) for the server you are trying to connect to.

$ mysql --help provides a full list of CLI options. The ones you need to look at in particular are:

  • -D / --database

  • -h / --host

  • -u / --user

  • -P / --port

Share:
8,591

Related videos on Youtube

Mike Meidl
Author by

Mike Meidl

Updated on September 18, 2022

Comments

  • Mike Meidl
    Mike Meidl over 1 year

    I am trying to just install a mysql client on a centos 7 server.

    I have a remote mysql server I need to connect to, I do not want to install the mysql server.

    From Centos 7 it will default to mariadb which is fine

    [root@server ~]# cat /etc/centos-release
    CentOS Linux release 7.7.1908 (Core)
    [root@server ~]# yum install mysql
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirror.umd.edu
     * epel: mirror.math.princeton.edu
     * extras: mirror.atlanticmetro.net
     * updates: packages.oit.ncsu.edu
    Resolving Dependencies
    --> Running transaction check
    ---> Package mariadb.x86_64 1:5.5.64-1.el7 will be installed
    --> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.64-1.el7 for package: 1:mariadb-5.5.64-1.el7.x86_64
    --> Running transaction check
    ---> Package mariadb-libs.x86_64 1:5.5.64-1.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =============================================================================================================================================================================================================================================
     Package                                                     Arch                                                  Version                                                         Repository                                           Size
    =============================================================================================================================================================================================================================================
    Installing:
     mariadb                                                     x86_64                                                1:5.5.64-1.el7                                                  base                                                8.7 M
    Installing for dependencies:
     mariadb-libs                                                x86_64                                                1:5.5.64-1.el7                                                  base                                                759 k
    
    Transaction Summary
    =============================================================================================================================================================================================================================================
    Install  1 Package (+1 Dependent package)
    
    Total download size: 9.5 M
    Installed size: 53 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/2): mariadb-libs-5.5.64-1.el7.x86_64.rpm                                                                                                                                                                           | 759 kB  00:00:00
    (2/2): mariadb-5.5.64-1.el7.x86_64.rpm                                                                                                                                                                                | 8.7 MB  00:00:03
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                                                                                        2.4 MB/s | 9.5 MB  00:00:03
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                                                                                                                                                        1/2
      Installing : 1:mariadb-5.5.64-1.el7.x86_64                                                                                                                                                                                             2/2
      Verifying  : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                                                                                                                                                        1/2
      Verifying  : 1:mariadb-5.5.64-1.el7.x86_64                                                                                                                                                                                             2/2
    
    Installed:
      mariadb.x86_64 1:5.5.64-1.el7
    
    Dependency Installed:
      mariadb-libs.x86_64 1:5.5.64-1.el7
    
    Complete!
    

    When I try to run mysql I get

    [root@server ~]# mysql
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    

    I cannot figure out how to start it

    [root@server ~]# systemctl start mysql
    Failed to start mysql.service: Unit not found.
    [root@server ~]# systemctl start mysqld
    Failed to start mysqld.service: Unit not found.
    [root@server ~]# systemctl start mariadb
    Failed to start mariadb.service: Unit not found.
    [root@server ~]#