How do I uninstall and reinstall MySQL?

January 24, 2017 588 views
MySQL Ubuntu 16.04

I did an install of Ubuntu 16.04 Server. I installed LAMP as I did the install. I set a password for MySQL at the time. I did an install of wordpress and tried to run it and got an error message can't connect with the database. I went into command line and MySQL is not starting up. States can't log in with Password NO. I didn't set NO as password. So I assume I need to uninstall MySQL and reinstall so I can put my correct password in. Any help ideas appreciated.

2 Answers


Before you remove your MySQL installation, try running the following command from the CLI.


If a password hasn't been set for root (for MySQL), that'll prompt you to set a password and run you through a series of steps to help clean up and secure MySQL (basic security).

Once set, then try running the command below to restart MySQL and see if you receive an error.

service mysql restart

We can troubleshoot to see what the issue is, as long as I know what errors you're receiving, or we can wipe the installation and start from scratch.

To remove MySQL, first you'd want to run:

apt-get remove -y mysql-*

and then:

apt-get purge -y mysql-*

The first command removes MySQL and associated packages while the second wipes configuration.

What I found out so far is I can't log in as root or do anything requiring the root password. So I have got to get the Servers password to somethig I know. I even tried to log in as root from the server itself. I am gong to also need to know how to set up the database Wordpress wants. I realize that is once I can get MySQL to start which it currently will not. So as I see my steps. 1. Get the root password set to something I know. 2. Get MySQL password to what is currently in wpconfig file. 3. Make sure the database Wordpress needs is right. Any help will sure be appreciated.

Have another answer? Share your knowledge.