Skip to content

Instantly share code, notes, and snippets.

@Javvadilakshman
Last active May 26, 2025 16:42
Show Gist options
  • Select an option

  • Save Javvadilakshman/7adbc72e1cd0cd1d66af to your computer and use it in GitHub Desktop.

Select an option

Save Javvadilakshman/7adbc72e1cd0cd1d66af to your computer and use it in GitHub Desktop.
Mysql Commands,Tips,Tricks,Fix etc....

mysql

### Commands,Snippets..
 1.Install/Unstall Mysql
 2.How to RESET root password

How to install/Uninstall Mysql in GNU/Linux by Lakshman.Javvadi

To check which version is there

dpkg -l | grep mysql

How to Install MySQL 5.5 on Ubuntu Server 12.04 LTS

sudo apt-get update
sudo apt-get install mysql-server-5.5

Once installation has completed, you just need to check that mysql is running. To do this, run

sudo netstat -tap | grep mysql	

Uninstalling mysql tested on ubuntu

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

Alias For MYSQLD Service Monitoring tested on Centos 6

alias ms="sudo service mysqld status";
alias ma="sudo service mysqld start";
alias mb="sudo service mysqld restart";
alias mc="sudo service mysqld stop";
alias mysql="sudo mysql";

###How To Reset Mysql Root Password in GNU/Linux

1.Stop  MySQL server process.
2.Start MySQL (mysqld) daemon process with the 
	"--skip-grant-tables"
  option so that it will not prompt for password.
3.Connect to mysql server as the root user.
4.Setup new mysql root account password i.e. reset mysql password.
5.Exit and restart MySQL server.

##Example :

1 : Stop Mysql Service

/etc/init.d/mysql stop

2 : Starting MySQL server without password

mysqld_safe --skip-grant-tables &

3: Connecting to mysql server using mysql client

mysql -u root

4: Setup MySQL new root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

5: Stop MySQL Server

/etc/init.d/mysql stop

6: Start MySQL server and test it

/etc/init.d/mysql start
 mysql -u root -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment