1. cd /home/ubuntu
    2. mkdir ipk && cd ipk
    3. wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
    4. tar -xzvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
    5. export MYSQL_HOME=/home/ubuntu/ipk/mysql-5.7.31-linux-glibc2.12-x86_64
    6. export MYSQL_BIN=$MYSQL_HOME/bin
    7. export PATH=$MYSQL_BIN:$PATH
    8. mkdir -p /home/ubuntu/mysql5.7-data
    9. touch /home/ubuntu/mysql5.7-data/my.ini
    10. sudo apt-get install libaio-dev
    11. mysqld --initialize --console -user=root --explicit_defaults_for_timestamp=off --datadir="/home/ubuntu/mysql5.7-data"
    12. 2020-09-08T03:10:16.874404Z 1 [Note] A temporary password is generated for root@localhost: jueZgGyXl3/7
    13. # 以安全模式启动mysql, 登录无需密码
    14. "mysqld" --defaults-file="/home/ubuntu/mysql5.7-data/my.ini" --user=root --skip-grant-tables --basedir="/home/ubuntu/ipk/mysql-5.7.31-linux-glibc2.12-x86_64" --datadir="/home/ubuntu/mysql5.7-data"
    15. # 登录
    16. "mysql" -u root --port=3306
    17. # 修改默认密码
    18. use mysql
    19. alter user user() identified by "root";
    20. update user set authentication_string=password('aaaa') where user='root';
    21. set password for 'root'@'localhost'=password('aaaa');
    22. FLUSH PRIVILEGES;
    23. # 关闭mysql
    24. mysqladmin shutdown --port=3306 -u root
    25. # 以一般模式启动
    26. nohup "mysqld" --defaults-file="/home/ubuntu/mysql5.7-data/my.ini" --user=root --basedir="/home/ubuntu/ipk/mysql-5.7.31-linux-glibc2.12-x86_64" --datadir="/home/ubuntu/mysql5.7-data" &
    27. #连接mysql
    28. "mysql" -u root --port=3306 -p
    29. # 开启root用户远程访问
    30. use mysql
    31. update user set host = '%' where user = 'root';
    32. # 单库备份
    33. C:\development\mysql5.7\base\bin\mysqldump.exe -h 192.168.1.200 --default-character-set=utf8 -u root -p $dbname > db1.sql
    34. # 单库恢复
    35. mysql --binary-mode=1 -uroot -p $dbname < ./db1.sql
    36. export PATH=$PATH:/home/ubuntu/ipk/jdk1.8.0_251/bin
    37. sudo vi /etc/rc.local

    停止mysql
    (友好的
    mysqladmin -uroot -p shutdown
    (暴力的
    killall mysql
    (不太确定的(就是我试过但当时没成功
    1.启动:mysql start
    2.停止:mysql stop
    3.重启:mysql restat