Thứ Hai, 7 tháng 1, 2019

Cài đặt MariaDB phiên bản 5.5

MariaDB là một sản phẩm mã đóng tách ra từ mã mở do cộng đồng phát triển của hệ quản trị cơ sở dữ liệu quan hệ MySQL nhằm theo hướng không phải trả phí với GNU GPL. MariaDB được định hướng để duy trì khả năng tương thích cao với MySQL, để đảm bảo khả năng hỗ trợ về thư viện đồng thời kết hợp một cách tốt nhất với các API và câu lệnh của MySQL. MariaDB đã có công cụ hỗ lưu trữ XtraDB thay cho InnoDB, cũng như một công cụ lưu trữ mới, Aria.

Dưới đây tôi sẽ hướng dẫn các bạn cách cài đặt MariaDB phiên bản 5.5

Phần 1: Cài đặt MariaDB 5.5

  • Ta sử dụng câu lệnh để tiến hành cài đặt:
[root@localhost ~] # yum -y install mariadb-server
  • Sử dụng câu lệnh sau để vào thư mục và tiến hành thay đổi:
[root@localhost ~] # vi /etc/my.cnf# Thêm dòng dưới đây sau phần [mysqld][mysqld]character-set-server=utf8
  • Lưu lại thay đổi và thoát ra bằng lệnh “:wq
  • Ta dùng câu lệnh để bắt đầu và kích hoạt MariaDB:
[root@localhost ~]# systemctl start mariadb [root@localhost ~]# systemctl enable mariadb 

Phần 2: Cài đặt ban đầu cho MariaDB

[root@localhost ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user.  If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): # Nhấn EnterOK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.# Đặt mật khẩuSet root password? [Y/n] # Nhấn chọn yNew password: # Điền password mớiRe-enter new password: # Nhập lại password mớiPassword updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.# Xóa người dùng ẩn danhRemove anonymous users? [Y/n] # Nhấn chọn y ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.# Không cho phép đăng nhập root từ xaDisallow root login remotely? [Y/n] # Nhấn chọn y ... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.# Xóa cơ sở dữ liệuRemove test database and access to it? [Y/n] # Nhấn chọn y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.# Tải lại các bảng đặc quyềnReload privilege tables now? [Y/n] # Nhấn chọn y ... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!
  • Kết nối với MariaDB bằng root
[root@localhost ~]# mysql -u root -p Enter password: # Nhập password mà bạn đã đặtWelcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 3Server version: 5.5.37-MariaDB MariaDB ServerCopyright (c) 2000, 2014, Oracle, Monty Program Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.# Hiển thị danh sách người dùngMariaDB [(none)]> select user,host,password from mysql.user; +------+-----------+-------------------------------------------+| user | host      | password                                  |+------+-----------+-------------------------------------------+| root | localhost | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || root | 127.0.0.1 | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || root | ::1       | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |+------+-----------+-------------------------------------------+3 rows in set (0.00 sec)# Hiển thị danh sách cơ sở dữ liệuMariaDB [(none)]> show databases; +--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema |+--------------------+3 rows in set (0.00 sec)MariaDB [(none)]> exitBye
  • Nếu Firewalld đang chạy và MariaDB cũng được sử dụng từ các Máy chủ từ xa, bạn hãy cho phép dịch vụ MariaDB sử dụng 3306 / TCP.
[root@localhost ~]# firewall-cmd --add-service=mysql --permanent success[root@localhost ~]# firewall-cmd --reload success

Vậy là đã xong

Chúc các bạn thành công!

Không có nhận xét nào:

Đăng nhận xét