cd /home/ubuntu
mkdir ipk && cd ipk
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
tar -xzvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
export MYSQL_HOME=/home/ubuntu/ipk/mysql-5.7.31-linux-glibc2.12-x86_64
export MYSQL_BIN=$MYSQL_HOME/bin
export PATH=$MYSQL_BIN:$PATH
mkdir -p /home/ubuntu/mysql5.7-data
touch /home/ubuntu/mysql5.7-data/my.ini
sudo apt-get install libaio-dev
mysqld --initialize --console -user=root --explicit_defaults_for_timestamp=off --datadir="/home/ubuntu/mysql5.7-data"
2020-09-08T03:10:16.874404Z 1 [Note] A temporary password is generated for root@localhost: jueZgGyXl3/7
# 以安全模式启动mysql, 登录无需密码
"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"
# 登录
"mysql" -u root --port=3306
# 修改默认密码
use mysql
alter user user() identified by "root";
update user set authentication_string=password('aaaa') where user='root';
set password for 'root'@'localhost'=password('aaaa');
FLUSH PRIVILEGES;
# 关闭mysql
mysqladmin shutdown --port=3306 -u root
# 以一般模式启动
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" &
#连接mysql
"mysql" -u root --port=3306 -p
# 开启root用户远程访问
use mysql
update user set host = '%' where user = 'root';
# 单库备份
C:\development\mysql5.7\base\bin\mysqldump.exe -h 192.168.1.200 --default-character-set=utf8 -u root -p $dbname > db1.sql
# 单库恢复
mysql --binary-mode=1 -uroot -p $dbname < ./db1.sql
export PATH=$PATH:/home/ubuntu/ipk/jdk1.8.0_251/bin
sudo vi /etc/rc.local
停止mysql
(友好的
mysqladmin -uroot -p shutdown
(暴力的
killall mysql
(不太确定的(就是我试过但当时没成功
1.启动:mysql start
2.停止:mysql stop
3.重启:mysql restat