I'm using Ubuntu 12.04 LTS.
There is on MySQL server situated remotely. I want to restart it.
Can someone please give me in detail step-by-step instructions to restart the MySQL server?
Following are the Database server details of MYSQL I got from phpMyAdmin UI:
Server: Localhost via UNIX socket
Server type: MySQL
Server version: 5.5.40-0ubuntu0.14.04.1 - (Ubuntu)
Protocol version: 10
User: root#localhost
Server charset: UTF-8 Unicode (utf8)
Can someone please help me?
SSH into the machine. Using the proper credentials and ip address, ssh root#128.0.0.1. This should provide you with shell access to the Ubuntu server.
Restart the mySQL service. sudo service mysql restart should do the job.
If your mySQL service is named something else like mysqld you may have to change the command accordingly or try this: sudo /etc/init.d/mysql restart
sudo service mysql stop;
sudo service mysql start;
If the above process will not work let's check one the given code above you can stop Mysql server and again start server
Another way is:
systemctl restart mysql
To restart mysql use this command
sudo service mysql restart
Or
sudo restart mysql
Reference
I SSH'ed into my AWS Lightsail wordpress instance, the following worked:
sudo /opt/bitnami/ctlscript.sh restart mysql
I learnt this here:
https://docs.bitnami.com/aws/infrastructure/mysql/administration/control-services/
I have had a problem with my WordPress site, the connection with MySql has gone away, and to get it back I had to restart the server. This has been an annoying issue as I do not have that high traffic on the site.
I tried to check if MySQL is up and make the cronjob restart it but that does not work that well. I have been looking at the log, using.
tail /var/log/mysql/error.log
In the log, I looked for shutdown messages or errors. I identified that the MySQL connection crashed when the server run out of memory, so why did it run out of memory. I started to optimize Mysql resources by using the optimization tool from Percona tools.
I also checked when my WordPress is running smoothly or what is causing heavy traffic peaks to your DB. One way is to increase the size of the server, I did not have that much traffic, so I installed the New Relic tool on my server to monitor the server resources to find out which processes are consuming memory.
I found out that the server did not have enough memory and MySQL can’t allocate what it needs so it crashes, what I did was add swap space to help this.
here is the method to Add Swap Space
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04
If that's not enough, you may need to consider upgrading to a larger server. Either way, you should take a closer look at your memory consumption to better understand the problem.
You can simply run from your local terminal
ssh username#www.remoteserver.com -- sudo service mysqld restart
What worked for me on an Amazon EC2 server was:
sudo service mysqld restart
Related
I run two servers one being a web hosting and one being a VPS. I want to use my MySQL server on my web hosting and done everything possible but it still will not work. I started by running the mysql command to grant privileges and it showed that the command went through fine although I still got a refused connection on my web server. I then got told to comment out bind_address in the config but once again it failed.
How can I go about fixing this?
Thanks.
You have to allow mysql to accept requests from remote not only localhost.
To do that you should edit /etc/mysql/mysql.conf.d/mysqld.cnf and change from:
bind-address = 127.0.0.1
to:
bind-address = 0.0.0.0
and restart the mysql server with this command: systemctl restart mysql.service
I'm trying to connect on my mysql database when I'm not on localhost - on localhost it's working. Everytime I wish to connect, I don't have any error, but only a timeout exec...
Here is what I've done so far
create a user on mysql who can access to any hosts("%")
purge the iptables
my port 3306 is opened (see screenshot)
the bind-address line is 0.0.0.0 in the mysqld.cnf file - I even tried to put in it comment - please note my.cnf sends to the mysqld.cnf file.
of course for every modification I've restarted the mysql server - and the server itself...
no firewall are setup...
I'm on Ubuntu 16.04 LTS, mysql and phpmyadmin are setup on it.
What I'm missing ?
Thank you for your help
Bastien
After you changed the bind address you restarted with systemctl restart mysql.service, yes?
Here's a very similar situation, try following all of these steps: Remote Connections Mysql Ubuntu
I think the flush privileges step will be a help to you.
So I installed xampp on my Linux machine running Ubuntu 14.04LTS. Now all of a sudden turns out when I try to connect to phpmyadmin it refuses to connect. I have already installed mysql separately as well but it doesn't seem to work. Any workaround for this?
The error that I get is :
MySQL said:
Cannot connect: invalid settings.
Connection for controluser as defined in your configuration failed.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Any reason why this happens and solution to it?
Go to http://localhost/security/ and then click on the link http://localhost/security/xamppsecurity.php.
After that change password for superuser to 'root'.
After that open your http://localhost/phpmyadmin/
As per the comment by RiggsFolly I was running two instances of MySQL
So both mysql servers do end up messing with phpmyadmin and this is how you shutdown the external mysql server while using xampp's inbuilt mysql server to connect successfully using phpmyadmin:
Use whichmysql to find the utility that is running
Navigate to the directory where the external MySQL service is running:
$ cd /usr/bin
$ mysqladmin shutdown
This shuts down the MySQL service running if at all it is running.
$ sudo service mysql stop
This helps as well if at all it will tell you the status of the service if it is already shut down.
Now we need to stop the Xampp mysql server so we navigate to /lampp/bin and again execute the same command to shut mysql server down.
$ cd /opt/lampp/bin
$ mysqladmin shutdown
Simply restart xampp and you should be good to go.
$ sudo /opt/lampp/lampp restart
I just fell into the same error. The solution I used was, stopping all the servers of xampp, exiting the program. Starting and stoping mysql then starting xampp again
Initial procedure before starting xampp:
sudo service mysql stop
sudo /etc/init.d/apache2 stop
If it bring the error as stated in this question, then follow the procedure below.
That is:
sudo /opt/lampp/lampp stop
sudo service mysql start
sudo service mysql stop
sudo /opt/lampp/lampp start
I have a centos server running nginx + php-fpm that will not connect to an external database for the purpose of a wordpress install.
I can ssh into the webs erver and run mysql to connect to the external mysql database fine but when trying to us php to connect to the database it fails.
Where should I look to resolve this issue?
It is possible for the problem to be related to selinux (as it was in my case today).
Try to run
setsebool httpd_can_network_connect_db on
Or if that doesn't work:
setenforce 0
Whenever I try to connect to MySQL to access phpmyadmin, it returns an error:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)
I also tried to start MySQL through my server's terminal:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
When I restarted MySQL it displayed:
Stopping MySQL database server mysqld
df: `/var/lib/mysql/.': No such file or directory
df: no file systems processed
/etc/init.d/mysql: ERROR: The partition with /var/lib/mysql is too full!
How might I resolve this?
I've seen that a couple of times. It has meant that the actual MySQL server instance was down for some reason. It was fixed by a simple call to:
service mysql restart
Edit
I just noticed your comment The partition with /var/lib/mysql is too full!. This means your drive is too full to run MySQL. You need to either talk to your server administrator or just clean up the HD, but this will keep breaking until more room is available.
Normally this happens when you have don't have the mysql daemon started. most distros you can start it by typing in
/etc/init.d/mysqld start
and that should get you going. I think it can sometimes also be that after you did your install you will need to give root a password.
mysqladmin -u root password <enter password here>
You may want to check first that the dameon is atually running by doing a
ps -ef | grep mysql
Credit