Cài đặt mysql-5.7.33 offline,
Bạn đã từng gặp trường hợp khi đi triển khai hệ thống cho các khách hàng có yêu cầu cao bảo mật, thì việc bạn cài os và sau đó phải cài đặt các phần mềm mà không được phép sử dụng internet, việc này nhiều lúc như là 1 cực hình, bạn nào làm không cẩn thận còn có thể lỗi cả OS, hôm nay mình viết bài này hy vọng giúp được các bạn đang cần cài đặt mysql offline trên môi trường linux, ở đây mình cài trên môi trường centos 7.
- Xóa maria db và các phiên bản mysql khác.
rpm -qa|grep mariadb
rpm -e –nodeps mariadb-libs
- Vào link sau https://downloads.mysql.com/archives/community/
và download mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar
Đẩy file này lên server centos 7 và tiến hành chạy lệnh sau để giải nén.
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
Nếu bạn chạy lệnh trên mà lỗi thì vào http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
Để download mysql-community-common-5.7.33-1.el7.x86_64.rpm (với phiên bản centos này thì mình đang bị lỗi thiếu bản này nên mình download bản này) và chạy lệnh
rpm -ivh mysql-community-common-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-devs–5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-devs-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.33-1.el7.x86_64.rpm
Sau khi cài đặt xong mysql thì bạn thực hiện các lệnh sau để đặt lại pass cho root.
- Stop mysql:
systemctl stop mysqld
- Set the mySQL environment option
systemctl set-environment MYSQLD_OPTS=”–skip-grant-tables”
- Start mysql usig the options you just set
systemctl start mysqld
- Login as root
mysql -u root;
- Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD(‘MyNewPassword’)
-> WHERE User = ‘root’ AND Host = ‘localhost’;
or thiss command set password for root@localhost = password(”MyNewPassword’);
mysql> FLUSH PRIVILEGES;
mysql> quit;
- Stop mysql
systemctl stop mysqld
- Unset the mySQL envitroment option so it starts normally next time
systemctl unset-environment MYSQLD_OPTS
- Start mysql normally:
systemctl start mysqld
- Try to login using your new password:
mysql -u root –p
- Set Mysql to boot automatically:
systemctl enable mysqld
Hy vọng bài viết hữu ích đối với các bạn.