how can I repair a mysql connection? - mysql

I use XAMPP 1.7.3
If I try to open phpMyAdmin it will try to open but eventually I'll have only a blank page, no errors.
If I try to connect with Navicat, the same thing, it will not be able to establish a connection.
And usually this process takes between 30% and 60% of the processor for more than 20 min.
If I stop and then start again the mysql server from XAMPP Control Panel the message is 'Mysql server started'.
But If I go to http://localhost/xampp/ and then 'Status' everything is 'Activated' EXCEPT ' MySQL database', 'SMTP Service', 'FTP Service' which are 'Deactivated'.
I think I crashed the Mysql server after I tried to make a database backup BUT the laptop closed before the backup was finished (the battery was discharged).
How can I repair the connection to the Mysql server?

First, make sure to double check the obvious, most likely these are not the issues since it happened after you closed your laptop, but it doesn't hurt to double check:
Make sure the MySQL service is running...
Also make sure that a firewall is not blocking port 3306...
This guide covers both MyISAM and InnoDB: http://www.softwareprojects.com/resources/programming/t-how-to-fix-mysql-database-myisam-innodb-1634.html
Now, assuming that the tables are MyISAM, you can repair them by following this guide:
http://colekcolek.com/2011/11/02/repair-corrupted-mysql-myisam-table/
Here is a way to do it for InnoDB: http://code.google.com/p/innodb-tools/

Related

mysql auto start on connection attempt

Is there a way to keep a mysql server stopped and for it to be started only after a connection is attempted.
I have a development mysql server in my ubuntu machine and I would like to keep it stopped unless needed and I don't want to have to remember to start it manually.
It's ok if this can be solved using something like vagrant or docker.
Bonus point if the server can be shut down after a configurable amount of idle time.
I remember openshift did something like this, if not connections were made the vm would be shut down and be started only after some connection was attempted to it.
Any MySQL client will attempt to connect to port 3306 (by default) to establish a MySQL connection. If the MySQL server is not running, there's nothing listening on port 3306, so the connection will simply fail.
To do what you're describing, there would need to be something listening on port 3306. Perhaps a proxy of some kind, like HAProxy or ProxySQL. Perhaps one of these can be configured to start a service on demand, but I've never seen anyone attempt to do that.
The reason is that it takes some time to start up a MySQL server process. At least a few seconds, but it could be much longer, depending on whether the server needs to perform crash recovery if it wasn't shut down cleanly last time it stopped. The proxy that starts it would have to keep re-trying the connection until it responds.
There's also a possibility that a downed MySQL server cannot be started, for example if there's a configuration problem that prevents it from starting, or a corrupted database. Then your client would try repeatedly to connect, with a delay each time, and never be able to start the service.
I wonder if what you really need is not MySQL, but an embedded database like SQLite.

Xampp Database Replication Setup Error

Scenario
I've been trying to set up mysql database replication on my xampp server but its not been working. I get the following error
and the error logs display the following message.
2017-12-28 10:14:37 10384 [ERROR] Slave I/O: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it). Internal MariaDB error code: 1593
2017-12-28 10:14:37 10384 [Note] Slave I/O thread exiting, read up to log 'FIRST', position 4
I understand what the error is saying but im not sure how to fix it, i've look online and around at various solutions and followed some of what theyve said. (Couldn't follow all some people are using linux or mysql in the command line so i couldnt follow but i tried an alternative).
I've been following this error since im trying to set this all up on xampp:
https://www.youtube.com/watch?v=nfsmnx24gxU
But its pretty outdated. Since i'm using xampp on windows there doesn't seem to be much up-to-date tutorials for this, they all show how to do it through linux terminal but obviously to me this isnt useful.
I'm also not sure how two separate servers are running on xampp in this scenario. Even if i visit "127.0.0.123" and "127.0.0.222" at the top of PhpMyAdmin it still shows that the current database is hosted on "127.0.0.1" so in this sense the replication process is slightly confusing me. Whats even more confusing is that it works flawlessly in the tutorial that i linked earlier.
I'm using the most up-to-date version of xampp, 28-12-2017.
Question
Does anyone know, on the current version of xampp, how to get past this error OR know of a tutorial that would help me set up replication on xampp on a windows computer.

Why MySQL Server shutdown after getting some hits

My website attracts more than 40 thousands unique visitors daily. When it gets 50 visitors simultaneously, sometimes the mySQL server shutdown itself and it gives error: "mysql cannot connect to database server"
the website on vps: its ram is 2 gb.
Is this due to low ram or low ranking features of vps?
When I restart the mySQL server, the problem is resolved.
The website is using wordpress as cms.
If there are some like me facing this issue and not know how they restart the mysql server, here it is: first login your whm and search MySQL, youll see restart MySQl button, click on it. http://www.saderesim.com/SxueS30

Force MySQL Shutdown

We have MySQL 5.1.45 running on a RedHat box. We needed to shut the box down for maintenance last week and had an issue.
We first closed down all connections.
Then we ran the MySQLAdmin/shutdown command.
The database appeared to hang. We waited for 30 minutes before trying Ctrl-C which gave us an error and we had to end up physically cycling the box.
Most of the documentation I can find points to InnoDB problems, but we are using MyISAM.
Is there a better way to shut down MySQL than running the Shutdown command?
Is there a way to force MySQL to shut down when it appears to hang?
service mysql stop ? I'm not so sure though...

vBulletin - MySQL server has gone away and table is marked as crashed

have some problems with server which run 5 years stable.
there is a vbulletin 3 forum running on the server.
i get crashed tables and MySQL server has gone away errors. not sure if lost connection can cause crashed tables or there is another reason for it.
there is no my.cnf file, so must be default mysql config, no big load. sometimes if i click a link i immediately get a white page, after reload page works fine - in log there is then a MySQL server has gone away error.
No a lost connection can not do that. But if MySQL crashes then you can get server has gone away, and the crash can corrupt the table.
You need to find out why MySQL is crashing. Worst case scenario is a bad hard disk - I hope you have good backups. If not do it NOW!