<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MySQL Basic Troubleshooting Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/mysql-basic-troubleshooting/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/mysql-basic-troubleshooting/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 27 Feb 2021 09:52:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>MySQL Basic Troubleshooting Guide &#124; MySQL common Issues</title>
		<link>https://www.scmgalaxy.com/tutorials/mysql-basic-troubleshooting-guide/</link>
					<comments>https://www.scmgalaxy.com/tutorials/mysql-basic-troubleshooting-guide/#comments</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Wed, 15 May 2013 13:39:01 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[BuildForge Server]]></category>
		<category><![CDATA[COmmon Problems in MysQL]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[issues.]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[MySQL Basic Issues]]></category>
		<category><![CDATA[MySQL Basic Problems]]></category>
		<category><![CDATA[MySQL Basic Troubleshooting]]></category>
		<category><![CDATA[MySQL common Issues]]></category>
		<category><![CDATA[MySQL Guide]]></category>
		<category><![CDATA[MySQL Issues]]></category>
		<category><![CDATA[MySQL Problems]]></category>
		<category><![CDATA[MySQL Troubleshooting]]></category>
		<category><![CDATA[MySQL Troubleshooting Guide]]></category>
		<category><![CDATA[MySQL Tutorial]]></category>
		<category><![CDATA[Troubleshoot MySQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2013/05/15/mysql-basic-troubleshooting-guide/</guid>

					<description><![CDATA[<p>PLEASE NOTE: I am currently reviewing this Article. How to check the mysql file location: &#62; which mysql &#62; locate [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/mysql-basic-troubleshooting-guide/">MySQL Basic Troubleshooting Guide | MySQL common Issues</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-3783 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2013/05/mysql-troubleshooting.png" alt="mysql-troubleshooting" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2013/05/mysql-troubleshooting.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2013/05/mysql-troubleshooting-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p>PLEASE NOTE: I am currently reviewing this Article.</p>
<p><strong>How to check the mysql file location:</strong><br />
&gt; which mysql<br />
&gt; locate mysql</p>
<p><strong>Check mysqld process is started or not?</strong><br />
&gt; service mysqld status<br />
&gt; “mysqld is stopped” – Means mysqld is not running<br />
&gt; “mysqld: unrecognized service” – Means mysqld is not set in service. This can be register using chkconfig under /etc/init.d.<br />
&gt; ps -eaf | grep mysqld</p>
<p><strong>To check if port 3306 is bind with mysqld or another program.</strong><br />
&gt; lsof -i TCP:3306<br />
&gt; netstat -lp | grep 3306<br />
&gt; netstat -tap | grep mysql<br />
&gt; ps -aux | grep mysql<br />
&gt; netstat -a -t &#8211; to show only tcp ports</p>
<p>Note: &#8211; if you could not found 3306 is listening with mysqld, then it must not be running or running with another ports. To find this, refer my.cnf and pid-file</p>
<p><strong>How to Stop mysqld?</strong><br />
&gt; /etc/init.d/mysqld stop<br />
&gt; kill &lt;pid&gt;<br />
&gt; /sbin/service mysqld start/stop/restart</p>
<p>If you have problems starting the server, here are some things to try:</p>
<p><strong>Check the error log to see why the server does not start.</strong><br />
The Location of error log file can be found in my.cnf or my.ini(windows). please refer below to know more about my.cnf file. The log file can be specified also in mysqld service resided<br />
under /etc/init.d/</p>
<p><strong>Make sure that the server knows where to find the data directory.</strong><br />
Make sure my.cnf file is set with &#8220;datadir&#8221; and its required ownership and permission. Make sure that the server can access the data directory. The ownership and permissions of the data directory and its contents must be set such that the server can read and modify them.</p>
<p><strong>Verify that the network interfaces the server wants to use are available. If the server starts but you cannot connect to it, you should make sure that you have an entry in /etc/hosts that<br />
looks like this:</strong><br />
127.0.0.1 localhost</p>
<p><strong>If mysqld is running, To find all the variable set using </strong><br />
&gt; mysqladmin -h hostname -p variables</p>
<p><strong>Issues 1:</strong><br />
Can&#8217;t start server: Bind on TCP/IP port: Address already in use<br />
Can&#8217;t start server: Bind on unix socket&#8230;<br />
<strong>Solution:</strong><br />
Use ps to determine whether you have another mysqld server running. If so, shut down the server before starting mysqld again.</p>
<p><strong>Issues 2:</strong><br />
mysqld will not start<br />
Can&#8217;t start server: Bind on TCP/IP port: Address already in use<br />
Do you already have another mysqld server running on port: 3306 ?<br />
<strong>Solution:</strong><br />
This may be due to 3306 port is being used or Disk Space issues. You can look up on the log file.</p>
<p><strong>Recovering a crashed MySQL server if the system itself or just the MySQL daemon corrupted table files</strong></p>
<p>You’ll see this when checking the /var/log/syslog, as the MySQL daemon checks tables during its startup.</p>
<p>Apr 17 13:54:44 live1 mysqld[2613]: 090417 13:54:44 [ERROR]<br />
/usr/sbin/mysqld: Table &#8216;./database1/table1&#8217; is marked as<br />
crashed and should be repaired</p>
<p>In this situation, Database and tables need to be repaired.</p>
<p>&gt; mysql -u root -p<br />
mysql&gt; REPAIR TABLE database1.table1;</p>
<p>This works, but there is a better way: First, using OPTIMIZE in combination with REPAIR is suggested and there is a command line tool only for REPAIR jobs. Consider this call:<br />
&gt; mysqlcheck -u username -p -o &#8211;auto-repair -v &#8211;optimize database_name</p>
<p>Using “mysqlcheck” is, that it can also be run against all databases in one run<br />
&gt; mysqlcheck -u root -p &#8211;auto-repair &#8211;check &#8211;optimize &#8211;all-databases</p>
<p>Recreating databases and tables the right way<br />
mysql&gt; show create database database1;</p>
<p><strong>How to find location of my.cnf (or my.ini on Windows)?</strong></p>
<p>Default options are read from the following files in the given order:<br />
/etc/my.cnf<br />
/etc/mysql/my.cnf<br />
/usr/etc/my.cnf<br />
~/.my.cnf</p>
<p>Or, on Windows:<br />
Default options are read from the following files in the given order:<br />
C:\Windows\my.ini<br />
C:\Windows\my.cnf<br />
C:\my.ini<br />
C:\my.cnf<br />
C:\Program Files\MySQL\MySQL Server 5.5\my.ini<br />
C:\Program Files\MySQL\MySQL Server 5.5\my.cnf</p>
<p><strong>This command also help you in linux to find my.conf file location&#8230;</strong><br />
&gt; strace mysql &#8220;;&#8221; 2&gt;&amp;1 | grep cnf</p>
<p><strong>Another Option to use following commands&#8230;</strong><br />
&gt; whereis my.cnf<br />
&gt; locate my.cnf<br />
&gt; find &#8211; -name my.cnf</p>
<p><strong>my.cnf will contain following&#8230;</strong><br />
datadir &#8211; The path to the MySQL data directory.<br />
tmpdir<br />
default-character-set<br />
default-storage-engine<br />
innodb_data_home_dir<br />
log-error- The location of log file.<br />
pid-file &#8211; The path name of the file in which the server should write its process ID.</p>
<p><strong>MySQL Performance Troubleshooting</strong><br />
There are three main utilities I’ll run to in a situation like this:</p>
<p>top<br />
First I’m going to use top to see if anything is hogging CPU on the machine. If there are non-mysql processes using a substantial percentage of the CPU cores, I’m going to want to havea look at what that is and see about limiting its use or moving it a dedicated server. If I see mysqld using up a lot of CPU, I know it’s working hard and will have to drill into what’shappening inside of MySQL (maybe some poorly written queries). If nothing is apparently chewing up the CPU time, I know that the problem is likely elsewhere.</p>
<p>vmstat 5<br />
I generally run this for at least two or three minutes to get a sense of what the CPU and memory use are like. I’m also watching to see how much time the CPU is stalled waiting for I/Orequests. Doing this for several minutes will make the occasional spikes really stand out and also allow for more time to catch those cron jobs that fire up every few minutes.</p>
<p>iostat -x 5 | grep sdb<br />
I’m going to run it with a short interval (5 or 10 seconds) and do so for several minutes. I’ll likely filter the output so that I only see the output for the most active disk or array (the onewhere all of MySQL’s data lives).</p>
<p>slow queries<br />
To find out about slow queries I’m going hope that the slow query log is enabled and the server has a sane long_query_time. But even the default of 10 seconds is helpful in truly badsituations.</p>
<p><strong>MySQL’s error log</strong><br />
I’ll also want to glance through MySQL’s error log to make sure nothing bad-looking has started to appear. To Find a error log file location, refer my.cnf file &#8220;log-error&#8221;.</p>
<p><strong>Network issues</strong><br />
telnet your_host_name tcp_ip_port_number.</p>
<p><strong>mysqladmin : </strong><br />
mysqladmin is a client for performing administrative operations. You can use it to check the server&#8217;s configuration and current status, to create and drop databases, and more.</p>
<p>mysqladmin -h hostname -p &lt;command_as_follows&gt;</p>
<p>&#8211;help, -? &#8211; Display a help message and exit.<br />
refresh &#8211; Flush all tables and close and open log files.<br />
variables &#8211; Display the server system variables and their values.<br />
flush-logs &#8211; Flush all logs.<br />
flush-privileges &#8211; Reload the grant tables (same as reload).<br />
flush-status &#8211; Clear status variables.<br />
password new-password &#8211; Set a new password. This changes the password to new-password for the account that you use with mysqladmin for connecting to the server.<br />
ping &#8211; Check whether the server is available<br />
processlist &#8211; Show a list of active server threads.<br />
shutdown &#8211; Stop the server.<br />
status &#8211; Display a short server status message.<br />
Uptime &#8211; The number of seconds the MySQL server has been running.<br />
Slow queries &#8211; The number of queries that have taken more than long_query_time seconds<br />
Open tables &#8211; The number of tables that currently are open.</p>
<p><strong>Reference</strong><br />
<a href="http://dev.mysql.com/doc/refman/5.5/en/mysqladmin.html" target="_blank" rel="noopener">http://dev.mysql.com/doc/refman/5.5/en/mysqladmin.html</a><br />
<a href="http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html" target="_blank" rel="noopener">http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html</a><br />
<a href="http://www.linux-mag.com/id/7473/" target="_blank" rel="noopener">http://www.linux-mag.com/id/7473/</a><br />
<a href="http://dev.mysql.com/doc/refman/5.1/en/starting-server.html" target="_blank" rel="noopener">http://dev.mysql.com/doc/refman/5.1/en/starting-server.html</a></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/mysql-basic-troubleshooting-guide/">MySQL Basic Troubleshooting Guide | MySQL common Issues</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/mysql-basic-troubleshooting-guide/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
