Question

How do I uninstall and reinstall MySQL?

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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@macmikeal

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

mysql_secure_installation

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.

Thanks. This helped

apt-get purge -y mysql-*