centso7 install Mariadb

安裝和配置Mariadb

看來以後不得不使用Mariadb數據庫了,儘早的熟悉;

[1]Install Mariadb for epel

yum -y install mariadb-server

Installed:
  mariadb-server.x86_64 1:5.5.37-1.el7_0

[2]Start Mariadb & 開機啓動

[root@mariadb ~]# systemctl start mariadb
[root@mariadb ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

[3]Configure Mariadb

[root@mariadb ~]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

#show info

MariaDB [(none)]> select user,host,password from mysql.user;
+------+------------------+----------+
| user | host             | password |
+------+------------------+----------+
| root | localhost        |          |
| root | mariadb.carso.cn |          |
| root | 127.0.0.1        |          |
| root | ::1              |          |
|      | localhost        |          |
|      | mariadb.carso.cn |          |
+------+------------------+----------+
6 rows in set (0.00 sec)

#設置root password

MariaDB [(none)]> set password for root@localhost=password('123.com');
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> set password for [email protected]=password('123.com');
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> set password for [email protected]=password('123.com');
Query OK, 0 rows affected (0.00 sec)

#::1這個是ipv6用戶,如果用不到可以刪除

MariaDB [(none)]> delete from mysql.user where user='root' and host='::1';
Query OK, 1 row affected (0.00 sec)

#安全考慮,刪除匿名用戶

MariaDB [(none)]> delete from mysql.user where user=''; 
Query OK, 2 rows affected (0.01 sec)

#show info

MariaDB [(none)]> select user,host,password from mysql.user;
+------+------------------+-------------------------------------------+
| user | host             | password                                  |
+------+------------------+-------------------------------------------+
| root | localhost        | *AC241830FFDDC8943AB31CBD47D758E79F7953EA |
| root | mariadb.cason.cn | *AC241830FFDDC8943AB31CBD47D758E79F7953EA |
| root | 127.0.0.1        | *AC241830FFDDC8943AB31CBD47D758E79F7953EA |
+------+------------------+-------------------------------------------+
3 rows in set (0.00 sec)

[4]驗證設置

MariaDB [(none)]> exit
Bye
[root@mariadb ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit
Bye


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章