Skip to content

Instantly share code, notes, and snippets.

@shenqihui
Last active October 30, 2024 06:09
Show Gist options
  • Save shenqihui/5f191cb9aeab8a377e49e9dfbde8846e to your computer and use it in GitHub Desktop.
Save shenqihui/5f191cb9aeab8a377e49e9dfbde8846e to your computer and use it in GitHub Desktop.
1404 安装 mysql

14的,下载 https://downloads.mysql.com/archives/get/p/23/file/mysql-server_5.7.26-1ubuntu14.04_amd64.deb-bundle.tar

16的,下载 https://downloads.mysql.com/archives/get/p/23/file/mysql-server_5.7.34-1ubuntu16.04_amd64.deb-bundle.tar

apt-get install libaio1 libmecab2 libjson-perl

下面要按顺序执行

dpkg -i mysql-common_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i libmysqlclient20_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i libmysqlclient-dev_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i libmysqld-dev_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i mysql-community-client_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i mysql-client_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i mysql-community-server_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i mysql-community-test_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i mysql-community-source_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i mysql-server_5.7.26-1ubuntu14.04_amd64.deb
dpkg -i mysql-testsuite_5.7.26-1ubuntu14.04_amd64.deb

18,20,22 的

下载 https://downloads.mysql.com/archives/get/p/23/file/mysql-server_5.7.35-1ubuntu18.04_amd64.deb-bundle.tar

sudo dpkg -i mysql-common_5.7.35-1ubuntu18.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.35-1ubuntu18.04_amd64.deb #此步需要输入数据的root密码
sudo dpkg -i libmysqlclient20_5.7.35-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.7.35-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.7.35-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.35-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-client_5.7.35-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-common_5.7.35-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-server_5.7.35-1ubuntu18.04_amd64.deb

如果改了目录,记得看看修改 /etc/apparmor.d/usr.sbin.mysqld 这里的 /var/lib , 重启 /etc/init.d/apparmor restart (注意如果这里是有ln关系的记得全路径也写全)

https://downloads.mysql.com/archives/community/
https://downloads.mysql.com/archives/get/p/23/file/mysql-community-server-5.7.32-1.el7.x86_64.rpm
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
之后 tar -xvf mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
yum localinstall ./*.rpm
service mysqld start
默认密码查看 /var/log/mysqld.log 的 password 关键字 (A temporary password is generated for root@localhost)
@shenqihui
Copy link
Author

shenqihui commented Jun 4, 2020

1804 的,修改路径 
apt-get install mysql-server
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY "123456";
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush PRIVILEGES;


services mysql stop
rsync -avz /var/lib/mysql/ /data/mysql/

/etc/mysql/mysql.conf.d/mysqld.cnf
- datadir 改成 /data/mysql/
- bind-address 改成 0.0.0.0


修改 /etc/apparmor.d/usr.sbin.mysqld 和 /usr/share/mysql/mysql-systemd-start
  /var/lib/mysql 相关的,增加多  /data/mysql (注意如果这里是有ln关系的记得全路径也写全)

service apparmor reload

mkdir /run/mysqld/
chmod a+rw /run/mysqld/

mkdir /run/mysqld/
chmod a+rw /run/mysqld/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment