Linux Installation of Binary MySQL and Method for Breaking MySQL Password
- 2021-06-28 14:34:08
- OfStack
1. Ensure that there is dependent libaio software in the system, if not:
yum -y install libaio
2. Unzip the binary MySQL package
tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local
3. Entry / usr / local
cd /usr/local
4. Modify the package name or create a soft connection
mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
ln -s mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
5. Add mysql users and groups
useradd -M -s /sbin/nologin mysql
6. Modify the current directory owner to create a new mysql user
chown -R mysql:mysql /usr/local/mysql
7. Initialize the mysql database (create default libraries and tables)
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
Initialize the database and a password will be generated at the end. Remember this password and use it to enter the database
8. Modify/etc/my.cnf file
vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid
9. Add mysql services to system services
cp mysql/support-files/mysql.server /etc/init.d/mysqld
chown +x /etc/init.d/mysqld
chkconfig --add mysqld
10. Turn on mysql
systemctl start mysqld
Check if the service is turned on:
netstat -lnpt |grep 3306
11. Create a soft link:
ln -s /usr/local/mysql/bin/* /bin/
12. Enter the mysql database:
mysql -uroot -p'初始化生成的密码'
exit exits the database
13. Modify the mysql password;
mysqladmin -uroot -p' Initialize generated password ' password ' The password you want to change '
==============================================================================
If you forget the mysql password:
1. Stop mysql first:
systemctl stop mysqld
2. Make sure there are no mysql-related processes:
ps aux |grep mysqld
3. Skip the authorization form to start the service:
tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local
0
mysql enters mysql database directly
mysql>show databases;
+-----------------------------+
| Database |
+-----------------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+-------------------------------+
4 rows in set (0.01 sec)
mysql> use mysql
mysql> show tables;
mysql> desc user;
mysql> select user,authentication_string (Password saved) from user;
mysql>update (Update) user set authentication_string=PASSWORD(' The password you want to set ') where user='root';
mysql>flush privileges; ( Refresh Authorization Form )
mysql>exit
Kill process after exit
ps aux |grep mysqld
kill-9 Process Number
Then turn on the service:
systemctl start mysqld
summary
The above is the Linux installation of binary MySQL and the method of breaking MySQL password introduced to you by this site. I hope it will help you. If you have any questions, please leave a message for me. This site will reply to you in time!