2

I am sorry if this has been posted before. I have been learning the use of MySQL and phpMyAdmin. Having followed an installation guide during an instructional course, I installed the above applications. However, the root user and password for the association between them seems to be incorrect.

I have tried removing and reinstalling, but this issue seems to follow on after the install as if there was a saved file or table containing old information regarding the previous install. Is there a way of fully removing both and all associated tables and files without having to resort to anything too drastic.

Thanks.

3

You can fully remove MySQL and phpMyAdmin by doing the following:

  1. Open your terminal (CTRL+ALT+T) and log in as root:

    sudo su
  2. Stop all MySql services that may still be running:

    service mysql stop
  3. Remove mysql and all its folders and files:

    apt-get remove --purge mysql*
    
    apt-get remove --purge mysql-server mysql-client mysql-common -y
    
    apt-get autoremove -y
    
    apt-get remove dbconfig-mysql
    
    rm -rf /etc/mysql /var/lib/mysql
    
    find / -iname 'mysql*' -exec rm -rf {} \;
  4. Remove PhpMyAdmin:

    apt-get purge phpmyadmin*
  5. Autoremove and clean all dependencies:

    apt-get autoremove && apt-get autoclean 
  • 1
    Many thanks all, that has sorted it. I have now re-installed and have it working correctly – Gareth Jones Nov 19 '18 at 16:58
  • @GarethJones I'm glad your problem was resolved... – Yufenyuy Veyeh Dider Nov 19 '18 at 21:14
1

Remove MySQL

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

Remove MySQL folders

sudo rm -rf /etc/mysql /var/lib/mysql

Delete all MySQL files from File System

sudo find / -iname 'mysql*' -exec rm -rf {} \;

Remove PhpMyAdmin

sudo apt-get purge phpmyadmin

Cleanup system (dependences)

sudo apt-get autoremove
sudo apt-get autoclean
1

If that was a production server, removing everything wouldn't be a solution. Probably your problem is related to the debian-sys-maint MySQL user - its password or its privileges. The correct solution for this issue is provided in this answer on Stack Overflow:

That’s because Debian has a MySQL account debian-sys-maint used for switching on/off and checking status. The password for that user should be the same as stored in /etc/mysql/debian.cnf. The file looks like this:

    # Automatically generated for Debian scripts. DO NOT TOUCH!
    [client]
    host     = localhost
    user     = debian-sys-maint
    password = <password>
    socket   = /var/run/mysqld/mysqld.sock
    [mysql_upgrade]
    host     = localhost
    user     = debian-sys-maint
    password = <password>
    socket   = /var/run/mysqld/mysqld.sock
    basedir  = /usr

If the password doesn't match (for example because you changed it manually) the init script won't work anymore. You should set the password according to the file. So

    mysql -u root -p
    # Then type MySQL root password
    GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<password>';
1

PHPMYADMIN

  1. sudo apt-get purge phpmyadmin
  2. sudo apt-get autoremove
  3. sudo ap-get autoclean

MYSQL

  1. sudo systemctl stop mysql
  2. sudo apt-get remove mysql*
  3. sudo apt-get purge mysql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.