Forums

machmandp
machmandp
Offline
Resolved
0 votes
Hi

somehow i have trashed the mysql database to the extent that i cannot login or change the password and i have tried loads of things i have found on the net.

As i had nothing in the database and want now to install a program which requires it i want to be able to reset mysql to the state it was when i first installed Clear

Can someone please advise me on how to either delete the databases and config files so i can get it all back up again or maybe uninstalling mysql and reinstalling may help (although i have tried this and the database still remained the same)

Thanks
Saturday, April 10 2010, 05:00 PM
Share this post:
Responses (8)
  • Accepted Answer

    Saturday, August 18 2012, 11:37 AM - #Permalink
    Resolved
    0 votes
    *This is from one of my older posts from 5x but the same should still apply

    Create a text file call it mysql-init copy it to your server

    Add this code to the contents
    UPDATE mysql.user SET Password=YOURPASSWORD GOES IN HERE('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;

    mysqld_safe --init-file=/home/me/mysql-init &

    The server executes the contents of the file named by the --init-file option at startup, changing each root account password.

    After the server has started successfully, delete /home/me/mysql-init.

    (replace /home/me/ to your directory path to the mysql-init file)

    This will flush out any stuffups also see http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html from the mysql 5.0 ref manual
    The reply is currently minimized Show
  • Accepted Answer

    Kismet
    Kismet
    Offline
    Monday, July 30 2012, 08:12 PM - #Permalink
    Resolved
    0 votes
    I just ran into the same problem and read through the post - seeing what you did to resolve yours. However, instead of deleting the /var/lib/mysql/mysql folder, I simply stopped the MySQL server (from the web interface), renamed the folder, and restarted it. The system recreated the database and prompted me to establish a password.

    Thought I'd share, just in case somebody else ran into this problem.
    The reply is currently minimized Show
  • Accepted Answer

    machmandp
    machmandp
    Offline
    Sunday, April 11 2010, 04:19 PM - #Permalink
    Resolved
    0 votes
    hi

    Perhaps i could have been clearer but in the end i only manually deleted the contents of the /var/lib/mysql/mysql directory (actually i copied them to another dir just in case it didnt work)

    now the mysql dir was empty mysql didnt think it had a database so then i ran

    mysql_init_db

    which recreated the database as though it was a first install.

    Obviously this only helps if you dont need any of the data in the databases but that was fine for me.

    As regards to uninstalling anything i ony tried that out after making a backup and it didnt work and you are right it's not a step to take lightly.

    Hope this helps
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, April 11 2010, 02:30 PM - #Permalink
    Resolved
    0 votes
    Please be careful when removing packages via the command line! it can take a whole lot of other packages with it due to dependancy issues.

    Anyway glad you fixed it :)
    The reply is currently minimized Show
  • Accepted Answer

    John
    John
    Offline
    Sunday, April 11 2010, 12:45 PM - #Permalink
    Resolved
    0 votes
    Hi machmandp,

    Glad you solved it but, for a future reference, can you please be more specific what commands you used ... ?!?
    In case someone wants to do this in the near future, without having to experiment and screw things up ... I for one am really good at that ;)

    Thanks,

    John
    The reply is currently minimized Show
  • Accepted Answer

    machmandp
    machmandp
    Offline
    Sunday, April 11 2010, 12:06 AM - #Permalink
    Resolved
    0 votes
    Got it sorted now thanks

    Tried the above but still the same
    in the end i just deleted the contents of the mysql dir and recreated the install by using the msql install command which was mysql_init_db
    this recreated the db as when it was installed
    The reply is currently minimized Show
  • Accepted Answer

    machmandp
    machmandp
    Offline
    Saturday, April 10 2010, 07:59 PM - #Permalink
    Resolved
    0 votes
    Thanks for reply

    I will give this a go but i will wait for a short while just in case anyone can help trashing the database first as this should be the easiest way.

    as i see it if i can completely get rid of the database inc users etc then i can recreate it by using mysql_secure_installation to recreate the databases to a clean install enviroment

    or at least i hope so

    anyhow thanks again and looking forward to more suggestions
    The reply is currently minimized Show
  • Accepted Answer

    John
    John
    Offline
    Saturday, April 10 2010, 05:57 PM - #Permalink
    Resolved
    0 votes
    Hi machmandp,

    I am only learning about how this works and if you follow my steps, you do it on your own responsibility, because there are 2 MySQL engines running on your ClearOS box and one is used by the system so ...

    Here's what I did:
    # yum --enablerepo=* list app-mysql
    Loading "kmod" plugin
    Loading "protect-packages" plugin
    Installed Packages
    app-system-mysql.i386 5.1-20 installed
    #
    Don't ask me why "app-mysql" is not listed ... :dry:

    According to what I understand what Ben is talking about, if you want to "yum" uninstall the additional MySQL, you could try this:
    yum --enablerepo=base-extras remove app-mysql

    Don't shoot the messenger, because I didn't test this and if it means that you have to do a clean install ... :blink: ... you better wait until someone confirms or denies this or prepare for the worst.

    And in case that this worked (let us know please), you could do this to reinstall it:
    yum --enablerepo=base-extras install app-mysql

    Otherwise I would not know, so good luck.

    John
    The reply is currently minimized Show
Your Reply