How can I log into the mysql 5.6 command line client and reset the root password in Centos7?
I read the following at this link, but it does not work:
1) sudo service mysqld stop
2) sudo service mysqld startsos
3) mysql -u root
4) Now you will be at mysql prompt. Here type:-
4.1) UPDATE mysql.user SET Password=PASSWORD('NewPassHere') WHERE User='root';
4.2) FLUSH PRIVILEGES;
4.3) quit;
5) sudo service mysqld restart
Step 1) above results in:
[root@localhost ~]# sudo service mysqld stop
Redirecting to /bin/systemctl stop mysqld.service
Failed to issue method call: Unit mysqld.service not loaded.
Step 3) above results in:
-bash: syntax error near unexpected token `('
When I change step 3 to UPDATE mysql.user SET Password='NewPassHere' WHERE User='root';
, I get the following error:
bash: UPDATE: command not found...
I do seem to be able to get into mysql when i type su -
to become root
and then type mysql - u root
at the next prompt. But then the above 5 step commands do not work, even when I remove the word sudo
and/or replace the word service
with systemctl
. How can I get working access to the mysql 5.6 command line in CentOS 7, starting with setting the root password?
Sometimes you can clobber your configuration. As such, it's easier to start over, as if the package had never been installed. In your case, we are looking at MySQL.
yum remove mysql mysql-server
mv /var/lib/mysql /var/lib/mysql_old_backup
rm -vR /var/lib/mysql
wget
to fetch the rpm that will update your repos):yum install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm && rpm -ivh mysql-community-release-el7-5.noarch.rpm
ls -1 /etc/yum.repos.d/mysql-community*
mysql-server
in the CentOS repository with the official package from upstream MySQL):yum install mysql-server
mysql_secure_installation
mysql -u root
systemctl
, part of systemd
to Start and Stop the daemon like so:systemctl start mysqld
External links referenced by this document: