Linux binary install MySQL and MySQL to crack passwords

1. Make sure the system has libaio software dependent, if not:

       yum -y install libaio

2. Extract the MySQL binary packages

      tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local

3. Go to / usr / local

     cd /usr/local

4. Modify the package name or create a soft link

    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 users and groups mysql

   useradd -M -s /sbin/nologin mysql

6. Modify the current directory for the new owner of the mysql user

  chown -R mysql:mysql /usr/local/mysql

7. initialize the mysql database (the establishment of the default library and table)

    /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

   After initializing the database in the final surface will generate a password to remember this password and use it to access 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 the mysql service to the system services

  cp mysql/support-files/mysql.server /etc/init.d/mysqld

  chown +x /etc/init.d/mysqld

  chkconfig --add mysqld

10. Turn mysql

  systemctl start mysqld

  View the next service is open: netstat -lnpt | grep 3306

11. Create a soft link:

  ln -s /usr/local/mysql/bin/* /bin/

12. enter the mysql database:

  mysql -uroot -p 'initialization generated password'

  exit out of the database

13. mysql modify the password;

  mysqladmin -uroot -p 'initialization generated password' password 'password you want to modify'

==============================================================================

If you forget your password mysql:

1. stop the run mysql:

          systemctl stop mysqld    

2. Make sure there is no process associated with mysql:

          ps aux | grep mysqld

3. Authorization Form skip start the service:

          mysqld_safe --skip-grant-tables & (to run in the background)

  direct access mysql mysql database

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 (save password) from user;

mysql> update (update) user set authentication_string = PASSWORD ( 'password you want to set a') where user = 'root';

mysql> flush privileges; (refresh Authorization Form)

mysql>exit

 

After exiting the first process of killing

   ps aux | grep mysqld

    kill -9 process ID

Then start the service: systemctl start mysqld

Guess you like

Origin www.cnblogs.com/canflyfish/p/11516942.html