This tutorial is a guide for the Ubuntu users on How to install MySQL server , PHPMyAdmin, Apache Server in Ubuntu from the Ubuntu terminal screen. I highly recommend to update ubuntu before any kind of installation.
MySQL is running or not in Ubuntu? Check status
Answer- Open a new terminal window. Now check the MySQL server status by using the command, if you have MySQL installed. Otherwise you shall not get the following screen.
The command is : /etc/init.d/mysql status
diet@ubuntu-Notebook-PC:~$ /etc/init.d/mysql status
diet@ubuntu-Notebook-PC:~$ sudo /etc/init.d/mysql status * /usr/bin/mysqladmin Ver 8.42 Distrib 5.5.46, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 5.5.46-0ubuntu0.14.04.2 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 1 min 4 sec Threads: 1 Questions: 110 Slow queries: 0 Opens: 48 Flush tables: 1
Alternate command: service mysql status
diet@ubuntu-Notebook-PC:~$ service mysql status
You will get a reply like the following line
mysql start/running, process 1124
But in some installation the just above command may not work.
How to stop a MySQL server from command line ?
The command will be – /etc/init.d/mysql stop , but you may need to use sudo also if this wont work as follows, the output line shown next. Ths full command will be the following:
sudo /etc/init.d/mysql stop
diet@ubuntu-Notebook-PC:~$ sudo /etc/init.d/mysql stop [sudo] password for diet:
You can also use : service mysql stop or sudo service mysql stop or stop mysql, just use the command inside double quote in the terminal.
Again run the following command to check the MySQL server status by using the command –
diet@ubuntu-Notebook-PC:~$ service mysql status mysql stop/waiting
Ubuntu- Install MySQL using commands in terminal
If MySQL is not installed, use any of the following command to install MySQL server:
$ sudo apt-get install mysql-server
You must provide a MySQL root user password during MySQL installation.
To install PHP5-MYSQL extension for Ubuntu you need to read this article, otherwise you may get this type of error : Your PHP installation appears to be missing the MySQL extension
Install phpMyAdmin in Ubuntu from the terminal
$ sudo apt-get install phpmyadmin apache2-utils
In this page you shall get good guide on Ubuntu phpMyAdmin installation issues
- Select Apache2 for the server
- Choose YES when asked about whether to Configure the database for phpmyadmin with dbconfig-common
- Enter your MySQL password
- Enter the password that you want to use to log into phpmyadmin
If you find that the in your web browser this URL http://localhost/phpmyadmin , showing nothing in your local PC then you should reconfigure phpMyAdmin, make sure that Apache Server is installed.
After the installation has completed, add phpmyadmin to the apache configuration.
From my experience, I may reach with localhost/phpmyadmin but fail to login, I have to reconfigure phpmyadmin, reset MySQL password, and then I may login without problems.
Reconfigure phpmyadmin
Ctrl+Alt+t to launch terminal
$ sudo dpkg-reconfigure phpmyadmin
Connection method for MySQL database for phpmyadmin: unix socket
Name of the database’s administrative user: root
Password of the database’s administrative user: mysqlsamplepassword
MySQL username for phpmyadmin: root
MySQL database name for phpmyadmin: phpmyadmin
Web server to reconfigure automatically: apache2