Solved

Manage MySQL via SSH

Posted on 2014-04-18
22
416 Views
Last Modified: 2014-04-18
I'm trying to boost the max_allowed_packet in mySQL. I can connect via SSH and change to root user. I've written the change to my.cnf, but I do not know the correct syntax to restart mysqld.

typing service mysqld restart in SSH returns "service command not found".
0
Comment
Question by:webdork
  • 11
  • 11
22 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009003
You need the full path.

Type /sbin/service mysld restart

HTH,
Dan
0
 

Author Comment

by:webdork
ID: 40009008
typing /sbin/service mysld restart

returns mysld unrecognized seervice
0
 

Author Comment

by:webdork
ID: 40009011
service
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009013
Yup, typo.

/sbin/service mysqld restart
0
 

Author Comment

by:webdork
ID: 40009023
Tried that.

root@ip-xx.xx.xxx.xxx [/home/xxxxxxx]# /sbin/service mysqld restart
mysqld: unrecognized service
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 40009037
What OS are you using? service is usually available on Redhat and variants (Fedora, CentOS etc.).

On others you can try:
sudo /etc/init.d mysqld restart

Or your daemon might be called otherwise.

use ps -aux | grep mysql
to check what processes are running that have mysql in their names.
0
 

Author Comment

by:webdork
ID: 40009043
Cent OS 5
0
 

Author Comment

by:webdork
ID: 40009048
root@ip-xx-xx-xxx-xxx [/home/xxxxxxxx]# sudo/etc/init.d mysqld restart
bash: sudo/etc/init.d: No such file or directory
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009050
OK, so service is available. What's the output of the ps command?
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009055
Tested on Centos 6 and these both work:

/sbin/service mysqld restart
/etc/init.d/mysqld restart
0
 

Author Comment

by:webdork
ID: 40009059
root@ip-xxxxxx [/home/xxxx]# ps
  PID TTY          TIME CMD
15818 pts/0    00:00:00 su
15823 pts/0    00:00:00 bash
16024 pts/0    00:00:00 ps
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009061
ps -aux | grep mysql
0
 

Author Comment

by:webdork
ID: 40009069
verbatim give bad syntax:

root@ip-xxxxxxxxxxx [/home/xxxxxxxxxx]# ps -aux | grep mysql
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009074
ps aux | grep mysql

It should list 3 processes containing "mysql".

It should work with the -, even with the warning...
0
 

Author Comment

by:webdork
ID: 40009076
here is the return from typing: ps aux | grep mysql



root@ip-xxxxxxxxxx [/home/xxxxxxxxx]# ps aux | grep mysql
root      3622  0.0  0.0   2564  1188 ?        S    Apr15   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/my              sql --pid-file=/var/lib/mysql/ip-xxxxxxxip.secureserver.net.pid
mysql     3725  0.0  2.1 331908 69116 ?        Sl   Apr15   1:07 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib              /mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/ip-xxxxxxxx.ip.secureserver.              net.err --pid-file=/var/lib/mysql/ip-5xxxxxxxxxxx.ip.secureserver.net.pid
root     16066  0.0  0.0   1952   560 pts/0    S+   09:51   0:00 grep mysql
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009086
OK. So the mysqld daemon is named "mysqld" and is running.

What's the output of
/etc/init.d/mysqld restart
0
 

Author Comment

by:webdork
ID: 40009089
root@ip-xxxxxxxxxxx [/home/xxxxxxxxxxx]# /etc/init.d/mysqld restart
bash: /etc/init.d/mysqld: No such file or directory
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009114
Then I don't understand. I don't have a CentOS 5 box to test on, but the same commands apply since CentOS 4 so it should work.
The exception is if you or someone else manually compiled MySQL and did not create the start/stop/restart scripts, but I don't think that's the case.

You can do it the hard way, by killing processes with pid 3622 and 3725 and then running:
/bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/ip-xxxxxxxip.secureserver.net.pid

Open in new window

but that will cause problems, as the pid file will still exist after a dirty exit and you might lose uncommitted transactions.
0
 

Author Comment

by:webdork
ID: 40009129
I got the answer from the server tech support in about 10 seconds (below).  The last tech support guy said "gee we cant help you with that" - go figure.

I'll certainly give you credit for the solution.


root@ip-xxxxxxxxxxxxx [~]# service mysql restart
Shutting down MySQL.... SUCCESS!
Starting MySQL.. SUCCESS!
root@ip-xxxxxxxxxxxxxxx [~]#
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009134
They renamed the service name from mysqld to mysql... Why?
0
 

Author Closing Comment

by:webdork
ID: 40009137
My best experience in 5 years with EE.

Quick with advice
Stayed engaged
Put up with my frustation
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40009150
Glad I could help!

PS: I own a small support company so I know a bit about frustrated clients :)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DNS Question 7 62
instanceof  operator in java 26 87
Updating PHP in Windows Server 2012 r2 22 103
Apache timeout remote connection if not port 80 10 72
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now