Hello everyone, this is a simple and quick guide to reset freebsd and mysql password and also check and optimize all mysql tables.
Probably most of you may know this already, but my target are those who are now giving their first steps in this matters, so, here it goes:
To reset mysql password, login in your machine and enter the following commands:
/usr/local/etc/rc.d/mysql-server stop
mysqld_safe --skip-grant-tables &
mysql -u root
use mysql
update user set password=PASSWORD('desiredpassword') where user='root';
flush privileges;
quit
service mysql-server restart
Where is written desiredpassword, enter your desired password.
Where is written root, enter the user of the database, usually its root or db_manage.
__________________________________________________ __________________________________________________ __________
To save time, and repair and optimize all databases at once, enter the following commandb (i recommend using this command at least once, when you finish setting up your files, and BEFORE starting to work on them):
mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
__________________________________________________ __________________________________________________ __________
To reset root password of FreeBSD, follow this steps:
1-Start FreeBSD
2-Press the space key [to stop the timer that boot freebsd]
3-Click on the number that identifies the option "Boot FreeBSD into single user mode", as seen on the image, this case is the number 4:
4-Press [ENTER] to boot as single user
5-After the message " When prompted Enter full pathname of shell or RETURN for /bin/sh: " press [ENTER]
6-To prevent future erros, use the following command to repair filesystem:
fsck -y [if it doesnt work, use fsck and enter y when asked]
7- After that, write this two commands:
mount -u /
mount -a
8-After it, enter this:
passwd
and write your desired password.
9- In the end, enter quit, and check if the password was modified.
Command without guide:
Reset password mysql
Repair and optimize all tables
Reset password root
Have fun